Ejemplo n.º 1
0
        public virtual Task Send(PersistentResponse response)
        {
            HeartBeat.MarkConnection(this);

            AddTransportData(response);
            return(Send((object)response));
        }
Ejemplo n.º 2
0
        private Task ProcessReceiveRequest(ITransportConnection connection, Action postReceive = null)
        {
            HeartBeat.UpdateConnection(this);
            HeartBeat.MarkConnection(this);

            if (TransportConnected != null)
            {
                TransportConnected().Catch();
            }

            // ReceiveAsync() will async wait until a message arrives then return
            var receiveTask = IsConnectRequest ?
                              connection.ReceiveAsync(TimeoutToken) :
                              connection.ReceiveAsync(MessageId, TimeoutToken);

            if (postReceive != null)
            {
                postReceive();
            }

            return(receiveTask.Then(response =>
            {
                if (response.Aborted)
                {
                    // If this was a clean disconnect then raise the event
                    OnDisconnect();
                }

                return Send(response);
            }));
        }
Ejemplo n.º 3
0
        public virtual Task Send(PersistentResponse response)
        {
            HeartBeat.MarkConnection(this);
            var data = _jsonSerializer.Stringify(response);

            OnSending(data);
            return(Context.Response.WriteAsync(data));
        }
Ejemplo n.º 4
0
 protected virtual void OnSending(string payload)
 {
     HeartBeat.MarkConnection(this);
     if (Sending != null)
     {
         Sending(payload);
     }
 }
Ejemplo n.º 5
0
        protected virtual void OnSendingResponse(PersistentResponse response)
        {
            HeartBeat.MarkConnection(this);

            if (SendingResponse != null)
            {
                SendingResponse(response);
            }
        }
Ejemplo n.º 6
0
        private Task ProcessReceiveRequest(ITransportConnection connection, Action postReceive = null)
        {
            HeartBeat.AddConnection(this);
            HeartBeat.MarkConnection(this);

            Action afterReceive = () =>
            {
                if (TransportConnected != null)
                {
                    TransportConnected().Catch();
                }

                if (postReceive != null)
                {
                    postReceive();
                }
            };

            return(InitializeResponse(connection)
                   .Then((c, pr) => ProcessMessages(c, pr), connection, afterReceive));
        }