public SCL_SocketServer(SCL_IClientSocketHandlerDelegate clientSocketHandlerDelegate, int maxClients = 1, string separatorString = "\n", int portNumber = 13000, Encoding encoding = null) { this.portNumber = portNumber; this.clientSocketHandlerDelegate = clientSocketHandlerDelegate; this.separatorString = separatorString; this.encoding = (encoding != null) ? encoding : Encoding.UTF8; this.clientHandlerThreads = ArrayList.Synchronized(new ArrayList()); this.maxClients = maxClients; // this is the local endpoing through which we shall listen // for connections. the ip is resolved dynamically and the // host is somewhat arbitrary (can be set by user) IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; this.localEndPoint = new IPEndPoint(ipAddress, this.portNumber); // create the socket to listen to the tcp communication this.listener = new TcpListener(this.localEndPoint.Address, this.portNumber); Debug.Log("Created TCP listener."); }
// Use this for initialization void Start() { Debug.Log("Hello From Me"); SCL_IClientSocketHandlerDelegate clientSocketHandlerDelegate = this; if (maxClients == 0) { maxClients = 10; } string separatorString = "&"; if (portNumber <= 1024) { portNumber = 8888; } if (ipAddress.Equals("")) { ipAddress = "127.0.0.1"; } Encoding encoding = Encoding.UTF8; this.socketServer = new SCL_SocketServer( clientSocketHandlerDelegate, maxClients, separatorString, ipAddress, portNumber, encoding); this.socketServer.StartListeningForConnections(); Debug.Log(String.Format( "Started socket server at {0} on port {1}", this.socketServer.LocalEndPoint.Address, this.socketServer.PortNumber)); }
void OnEnable() { SCL_IClientSocketHandlerDelegate clientSocketHandlerDelegate = this; socketServer = new SCL_SocketServer(clientSocketHandlerDelegate, 5, "\n", port, Encoding.UTF8); socketServer.StartListeningForConnections(); }
public SCL_ClientSocketHandler(TcpClient client, SCL_IClientSocketHandlerDelegate socketDelegate, string separatorString, Encoding encoding) { this.client = client; this.encoding = encoding; this.separatorSequence = separatorString; this.separatorSequenceChars = separatorString.ToCharArray(); this.socketDelegate = socketDelegate; }
// Use this for initialization void Start() { Debug.Log("Hello From Me"); SCL_IClientSocketHandlerDelegate clientSocketHandlerDelegate = this; int maxClients = 1; string separatorString = "&"; int portNumber = 13000; Encoding encoding = Encoding.UTF8; this.socketServer = new SCL_SocketServer( clientSocketHandlerDelegate, maxClients, separatorString, portNumber, encoding); this.socketServer.StartListeningForConnections(); Debug.Log(String.Format( "Started socket server at {0} on port {1}", this.socketServer.LocalEndPoint.Address, this.socketServer.PortNumber)); }
//Initialization void Start() { for (int i = 0; i < maxObjects; i++) { cubeArray[i].valid = false; cubeArray[i].cubeObj = null; //GameObject object that is physically placed in the Unity Engine cubeArray[i].cFlag = false; //"create" flag for FixedUpdate() method cubeArray[i].dFlag = false; //"destroy" flag for FixedUpdate() method cubeArray[i].mFlag = false; //"move" flag for FixedUpdate() method } SCL_IClientSocketHandlerDelegate socketDelegate = this; int maxClients = 1; string separatorString = "+"; int portNumber = 13000; Encoding encoding = Encoding.UTF8; this.socketServer = new SCL_SocketServer(socketDelegate, maxClients, separatorString, portNumber, encoding); this.socketServer.StartListeningForConnections(); Debug.Log(String.Format( "Started socket server at {0} on port {1}", this.socketServer.LocalEndPoint.Address, this.socketServer.PortNumber)); }