public AltClientSocketHandler(System.Net.Sockets.TcpClient client, AltIClientSocketHandlerDelegate clientSocketHandlerDelegate, string separatorString, System.Text.Encoding encoding) { Client = client; Encoding = encoding; SeparatorSequence = separatorString; SeparatorSequenceChars = separatorString.ToCharArray(); ClientSocketHandlerDelegate = clientSocketHandlerDelegate; ToBeKilled = false; }
public void StartSocketServer() { AltIClientSocketHandlerDelegate clientSocketHandlerDelegate = this; int maxClients = 1; System.Text.Encoding encoding = System.Text.Encoding.UTF8; _socketServer = new AltSocketServer( clientSocketHandlerDelegate, SocketPortNumber, maxClients, requestEndingString, encoding); _socketServer.StartListeningForConnections(); AltUnityPopUpText.text = "Waiting for connection" + System.Environment.NewLine + "on port " + _socketServer.PortNumber + "..."; UnityEngine.Debug.Log(string.Format( "AltUnity Server at {0} on port {1}", _socketServer.LocalEndPoint.Address, _socketServer.PortNumber)); }
public AltSocketServer(AltIClientSocketHandlerDelegate clientSocketHandlerDelegate, int portNumber = 13000, int maxClients = 1, string separatorString = "\n", System.Text.Encoding encoding = null) { this.portNumber = portNumber; ClientSocketHandlerDelegate = clientSocketHandlerDelegate; SeparatorString = separatorString; Encoding = encoding ?? System.Text.Encoding.UTF8; ClientHandlerThreads = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList()); this.maxClients = maxClients; System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse("127.0.0.1"); localEndPoint = new System.Net.IPEndPoint(ipAddress, this.portNumber); Listener = new AltTcpListener(localEndPoint.Address, this.portNumber); UnityEngine.Debug.Log("Created TCP listener."); }