Ejemplo n.º 1
0
        private Task ProcessConnectRequest(ITransportConnection connection)
        {
            if (Connected != null)
            {
                bool newConnection = HeartBeat.AddConnection(this);

                // Return a task that completes when the connected event task & the receive loop task are both finished
                return(TaskAsyncHelper.Interleave(ProcessReceiveRequestWithoutTracking, () =>
                {
                    if (newConnection)
                    {
                        return Connected();
                    }
                    return TaskAsyncHelper.Empty;
                },
                                                  connection, Completed));
            }

            return(ProcessReceiveRequest(connection));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 private Task ProcessReceiveRequest(ITransportConnection connection, Action postReceive = null)
 {
     HeartBeat.AddConnection(this);
     return(ProcessReceiveRequestWithoutTracking(connection, postReceive));
 }