protected virtual void AcceptCallback(IAsyncResult ar) { if (this.KeepServerAlive) { this.AsyncAccept(); } WebSocketServer.Client.AbsRequestHandler cleintHandler = null; try { if (ar.IsCompleted && null != this._mainSocket) { //Socket mainSoket = (Socket)ar.AsyncState; Socket client = ((Socket)ar.AsyncState).EndAccept(ar); lock (lockObj) { } cleintHandler = new WebSocketServer.Client.AbsRequestHandler(); cleintHandler.ClientSocket = client; cleintHandler.DoCommunicate(); /* * byte[] result; * int receive_size = Receive(client, out result); * string recieveData = Encoding.UTF8.GetString(result, 0, receive_size); * //WriteLog(recieveData); * Logger.WriteLog(recieveData); */ } } catch (Exception ex) { //WriteLog("[Error]" + ex.Message); Logger.WriteLog("[Error]" + ex.Message); if (null != cleintHandler) { cleintHandler.CancelAsync(); } } }
protected virtual void AcceptCallback(IAsyncResult ar) { if (this.KeepServerAlive) this.AsyncAccept(); WebSocketServer.Client.AbsRequestHandler cleintHandler = null; try { if (ar.IsCompleted && null != this._mainSocket) { //Socket mainSoket = (Socket)ar.AsyncState; Socket client = ((Socket)ar.AsyncState).EndAccept(ar); lock (lockObj) { } cleintHandler = new WebSocketServer.Client.AbsRequestHandler(); cleintHandler.ClientSocket = client; cleintHandler.DoCommunicate(); /* byte[] result; int receive_size = Receive(client, out result); string recieveData = Encoding.UTF8.GetString(result, 0, receive_size); //WriteLog(recieveData); Logger.WriteLog(recieveData); */ } } catch (Exception ex) { //WriteLog("[Error]" + ex.Message); Logger.WriteLog("[Error]" + ex.Message); if (null != cleintHandler) { cleintHandler.CancelAsync(); } } }