public virtual Task Send(PersistentResponse response) { HeartBeat.MarkConnection(this); AddTransportData(response); return(Send((object)response)); }
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); })); }
public virtual Task Send(PersistentResponse response) { HeartBeat.MarkConnection(this); var data = _jsonSerializer.Stringify(response); OnSending(data); return(Context.Response.WriteAsync(data)); }
protected virtual void OnSending(string payload) { HeartBeat.MarkConnection(this); if (Sending != null) { Sending(payload); } }
protected virtual void OnSendingResponse(PersistentResponse response) { HeartBeat.MarkConnection(this); if (SendingResponse != null) { SendingResponse(response); } }
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)); }