public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d, bool StartNow, EncryptionType encryptionType) { sock = cl; sock.SendTimeout = 20000; // 20 seconds timeout sock.LingerState = new LingerOption(false, 0); sock.NoDelay = true; // NOT WORKING IN EMULATOR sock.ExclusiveAddressUse = true; buffer = ""; OnReadBytes = readevt; encType = encryptionType; encStage = 0; encComplete = encType == EncryptionType.None; OnRead = read; MessageType = MessageType.EndMarker; dir = d; delim = "\n"; id = NextID; // Assign each client an application-unique ID unchecked { NextID++; } //t = new ClientThread(this); if (StartNow) { BeginReceive(); } }
private static void Connect( CancelableTcpListener server, InboundCrossThread crossThread, MessageTransferLookUp lookUp ) { InboundMultiMessageSender sender = new InboundMultiMessageSender(); InboundMultiMessageSubscription subscription = new InboundMultiMessageSubscription(server.GetCancellationTokenSource()); server.Start(); Debug.Log("Server dispatching connections"); crossThread.AcceptStream(new NetworkMessageMultiStream(sender.GetSender(), subscription)); while (true) { var guid = server.Accept(); Debug.Log("Server connection established: " + guid); var client = server.GetClient(guid); crossThread.Schedule((parent) => { var clientSender = ConnectionWrite.Write(client, lookUp); var clientSubscription = ConnectionRead.Read(client, parent, lookUp); sender.AddClientSender(guid, clientSender); subscription.AddClientSubscription(guid, clientSubscription); }); } }
public static NetworkMessageStream Open(int port, string address, MonoBehaviour parent, MessageTransferLookUp lookUp) { var addr = IPAddress.Parse(address); var client = new CancelableTcpClient(new TcpClient(address, port)); var messageData = NetworkMessageSerializer.Get(lookUp); var recieve = ConnectionRead.Read(client, parent, lookUp); MessageHandler send = ConnectionWrite.Write(client, lookUp); return(new NetworkMessageStream(send, recieve)); }
public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d, bool StartNow, EncryptionType encryptionType) { sock = cl; buffer = ""; OnReadBytes = readevt; encType = encryptionType; encStage = 0; encComplete = encType == EncryptionType.None; OnRead = read; MessageType = MessageType.EndMarker; dir = d; delim = "\n"; id = NextID; // Assign each client an application-unique ID unchecked { NextID++; } //t = new ClientThread(this); if (StartNow) { BeginReceive(); } }
public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d, bool StartNow, EncryptionType encryptionType) { sock = cl; buffer = ""; OnReadBytes = readevt; encType = encryptionType; encStage = 0; encComplete = encType == EncryptionType.None; OnRead = read; MessageType = MessageType.EndMarker; dir = d; delim = "\n"; id = NextID; // Assign each client an application-unique ID unchecked { NextID++; } //t = new ClientThread(this); if (StartNow) BeginReceive(); }
//public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d) : this(cl, read, readevt, d, true, EncryptionType.None) {} public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d, bool StartNow) : this(cl, read, readevt, d, StartNow, EncryptionType.None) { }
public ClientInfo(Socket cl, ConnectionRead read, ConnectionReadBytes readevt, ClientDirection d, bool StartNow, EncryptionType encryptionType) { sock = cl; sock.SendTimeout=20000; // 20 seconds timeout sock.LingerState = new LingerOption(false,0); sock.NoDelay = true; // NOT WORKING IN EMULATOR sock.ExclusiveAddressUse = true; buffer = ""; OnReadBytes = readevt; encType = encryptionType; encStage = 0; encComplete = encType == EncryptionType.None; OnRead = read; MessageType = MessageType.EndMarker; dir = d; delim = "\n"; id = NextID; // Assign each client an application-unique ID unchecked { NextID++; } //t = new ClientThread(this); if (StartNow) BeginReceive (); }