void wsServer_NewSessionConnected(WebSocketSession session) { Console.WriteLine("enter wsServer_NewSessionConnected()"); AcceptChannelAsyncResult aysncResult = null; lock (this.asyncResultQueue) { if (this.asyncResultQueue.Count == 0) { return; } aysncResult = this.asyncResultQueue.Dequeue(); } WebSocketServerChannel channel = new WebSocketServerChannel(this.encoderFactory.Encoder, this.bufferManager, this, session); lock (this.channelMap) { this.channelMap[session] = channel; } aysncResult.Complete(channel); // log logger.InfoFormat("new server channel[{0}] created. total channel number: [{1}]", session.RemoteEndPoint, this.channelMap.Count); }
void wsServer_NewDataReceived(WebSocketSession session, byte[] value) { Console.WriteLine("enter wsServer_NewDataReceived()"); Console.WriteLine("data received. [{0}]", value.Length); logger.DebugFormat("data received. [{0}]", value.Length); WebSocketServerChannel channel = null; lock (this.channelMap) { if (!this.channelMap.TryGetValue(session, out channel)) { // log Console.WriteLine("session not found!!!"); logger.ErrorFormat("session [{0}] found for data length [{1}]!", session.RemoteEndPoint, value != null ? value.Length.ToString() : "null"); return; } } // log logger.DebugFormat("data recieved [{0}] at channel [{1}].", value != null ? value.Length.ToString() : "null", session.RemoteEndPoint); // receive data channel.ReceiveData(value); }
void wsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { WebSocketServerChannel channel = null; lock (this.channelMap) { if (!this.channelMap.TryGetValue(session, out channel)) { // log logger.ErrorFormat("session[{0}] not found in channel map", session.RemoteEndPoint); Console.WriteLine("session not found!!!"); return; } this.channelMap.Remove(session); } //channel.ReceiveData(null); channel.Close(); // log logger.InfoFormat("channel[{0}] colsed. total channel number [{1}]", session.RemoteEndPoint, this.channelMap.Count); }
public ReadDataAsyncResultServer(WebSocketServerChannel channel, AsyncCallback callback, object state) : base(callback, state) { }