mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Updated Telepathy to latest version. Fixes a bug where connect couldn't be called twice.
This commit is contained in:
parent
bafd9d1b28
commit
b70fa177d1
@ -6,17 +6,19 @@ namespace Telepathy
|
||||
{
|
||||
public class Client : Common
|
||||
{
|
||||
TcpClient client = new TcpClient();
|
||||
TcpClient client;
|
||||
Thread thread;
|
||||
|
||||
public bool Connecting
|
||||
{
|
||||
get { return thread != null && thread.IsAlive && !client.Connected; }
|
||||
get { return thread != null && thread.IsAlive &&
|
||||
client != null && !client.Connected; }
|
||||
}
|
||||
|
||||
public bool Connected
|
||||
{
|
||||
get { return thread != null && thread.IsAlive && client.Connected; }
|
||||
get { return thread != null && thread.IsAlive &&
|
||||
client != null && client.Connected; }
|
||||
}
|
||||
|
||||
// the thread function
|
||||
@ -59,6 +61,10 @@ public void Connect(string ip, int port)
|
||||
// not if already started
|
||||
if (Connecting || Connected) return;
|
||||
|
||||
// TcpClient can only be used once. need to create a new one each
|
||||
// time.
|
||||
client = new TcpClient();
|
||||
|
||||
// clear old messages in queue, just to be sure that the caller
|
||||
// doesn't receive data from last time and gets out of sync.
|
||||
// -> calling this in Disconnect isn't smart because the caller may
|
||||
@ -88,6 +94,7 @@ public void Disconnect()
|
||||
// (maybe it's Unity? maybe Mono?)
|
||||
client.GetStream().Close();
|
||||
client.Close();
|
||||
client = null;
|
||||
}
|
||||
|
||||
public bool Send(byte[] data)
|
||||
|
Loading…
Reference in New Issue
Block a user