コード例 #1
0
        void Dispatch(FramingData data)
        {
            if (data == null)
            {
                // FUTURE: Error handling
                return;
            }

            dataReceivedCallback(data);
        }
コード例 #2
0
        FramingData EndReceive(Socket listenSocket, IAsyncResult result)
        {
            // if we've started the shutdown process, then we've disposed
            // the socket and calls to socket.EndReceive will throw
            if (closed)
            {
                return(null);
            }

            byte[] buffer = ((SocketReceiveState)result.AsyncState).Buffer;
            Debug.Assert(buffer != null);
            FramingData data = null;

            try
            {
                int count = 0;

                lock (ThisLock)
                {
                    // if we've started the shutdown process, socket is disposed
                    // and calls to socket.EndReceive will throw
                    if (!closed)
                    {
                        EndPoint dummy = CreateDummyEndPoint(listenSocket);
                        count = listenSocket.EndReceiveFrom(result, ref dummy);
                    }
                }

                if (count > 0)
                {
                    data = FramingCodec.Decode(new ArraySegment <byte>(buffer, 0, count));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error in completing the async receive via EndReceiveFrom method.");
                Debug.WriteLine(e.ToString());
            }
            finally
            {
                if (data == null)
                {
                    this.bufferManager.ReturnBuffer(buffer);
                    buffer = null;
                }
            }

            return(data);
        }
コード例 #3
0
        void OnDataReceived(FramingData data)
        {
            Uri uri = data.To;
            App app = appQueue.Lookup(uri);
            if (app == null)
            {
                // Not found
                return;
            }

            lock (ThisLock)
            {
                bool firstStart;
                app.EnsureStarted(out firstStart);

                if (firstStart)
                {
                    WasHelper.OpenListenerChannelInstance(this.protocolHandle,
                        app.AppPoolId, app.Instance.Id, app.Instance.Serialize());
                }

                app.EnqueueAndDispatch(data);
            }
        }
コード例 #4
0
        void ContinueReceiving(IAsyncResult receiveResult, Socket listenSocket)
        {
            bool continueReceiving = true;

            while (continueReceiving)
            {
                FramingData data = null;

                if (receiveResult != null)
                {
                    data          = EndReceive(listenSocket, receiveResult);
                    receiveResult = null;
                }

                lock (ThisLock)
                {
                    if (!closed)
                    {
                        EndPoint dummy  = CreateDummyEndPoint(listenSocket);
                        byte[]   buffer = this.bufferManager.TakeBuffer(maxMessageSize);
                        receiveResult = listenSocket.BeginReceiveFrom(buffer, 0, buffer.Length,
                                                                      SocketFlags.None, ref dummy, this.onReceive, new SocketReceiveState(listenSocket, buffer));
                    }
                }

                if (receiveResult == null || !receiveResult.CompletedSynchronously)
                {
                    continueReceiving = false;
                    Dispatch(data);
                }
                else if (data != null)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(DispatchCallback), data);
                }
            }
        }
コード例 #5
0
        void Dispatch(FramingData data)
        {
            if (data == null)
            {
                // FUTURE: Error handling
                return;
            }

            dataReceivedCallback(data);
        }
コード例 #6
0
ファイル: AppManager.cs プロジェクト: ssickles/archive
 public RequestContext(FramingData data)
 {
     this.data = data;
     this.contextDequeued = new ManualResetEvent(false);
 }
コード例 #7
0
ファイル: AppManager.cs プロジェクト: ssickles/archive
        public void EnqueueAndDispatch(FramingData data)
        {
            // Schedule message dispatch
            RequestContext context = new RequestContext(data);
            messageQueue.EnqueueAndDispatch(context, context.OnContextDequeued, false);

            // Wait for the message to be dequeued.
            context.OnContextEnqueued();
        }
コード例 #8
0
        public void Dispatch(FramingData data)
        {
            UdpChannelListener channelListener = channelListeners.Lookup(data.To);

            channelListener.OnRawMessageReceived(data.Payload);
        }
コード例 #9
0
 public void OnDataReceived(FramingData data)
 {
     base.Dispatch(data);
 }
コード例 #10
0
 public void Dispatch(FramingData data)
 {
     // Dispatch the message on a new thread
     ThreadPool.QueueUserWorkItem(new WaitCallback(OnDispatchMessage), data);
 }
コード例 #11
0
 public void Dispatch(FramingData data)
 {
     UdpChannelListener channelListener = channelListeners.Lookup(data.To);
     channelListener.OnRawMessageReceived(data.Payload);
 }
コード例 #12
0
 public void OnDataReceived(FramingData data)
 {
     base.Dispatch(data);
 }
コード例 #13
0
        public void OnDataReceived(FramingData data)
        {
            ServiceHostingEnvironment.EnsureServiceAvailable(data.To.LocalPath);

            base.Dispatch(data);
        }