コード例 #1
0
            static void OnAccept(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                AcceptChannelAsyncResult thisPtr = (AcceptChannelAsyncResult)result.AsyncState;

                Exception completionException = null;
                bool      completeSelf        = false;

                try
                {
                    completeSelf = thisPtr.CompleteAccept(result);
                }
                catch (Exception e)
                {
                    completeSelf        = true;
                    completionException = e;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
        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);
        }
        protected override IAsyncResult OnBeginAcceptChannel(TimeSpan timeout, AsyncCallback callback, object state)
        {
            AcceptChannelAsyncResult asyncResult;

            asyncResult = new AcceptChannelAsyncResult(callback, state);
            lock (this.asyncResultQueue)
            {
                this.asyncResultQueue.Enqueue(asyncResult);
            }
            return(asyncResult);
        }
コード例 #4
0
            public static IDuplexSessionChannel End(IAsyncResult result)
            {
                AcceptChannelAsyncResult thisPtr = AsyncResult.End <AcceptChannelAsyncResult>(result);

                return(thisPtr.channel);
            }
コード例 #5
0
 protected override IDuplexSessionChannel OnEndAcceptChannel(IAsyncResult result)
 {
     return(AcceptChannelAsyncResult.End(result));
 }
コード例 #6
0
 protected override IReplyChannel OnEndAcceptChannel(IAsyncResult result)
 {
     return(AcceptChannelAsyncResult.End(result));
 }
コード例 #7
0
            public static IReplyChannel End(IAsyncResult result)
            {
                AcceptChannelAsyncResult thisPtr = AsyncResult.End <AcceptChannelAsyncResult>(result);

                return(thisPtr.channel);
            }