コード例 #1
0
        public static ConnectionHeartbeatRequest Execute(IConnectionManager manager, ICountdownTimer timer, Action <bool, ErrorInfo> callback)
        {
            ConnectionHeartbeatRequest request = new ConnectionHeartbeatRequest();

            if (manager.Connection.State != Realtime.ConnectionState.Connected)
            {
                if (callback != null)
                {
                    callback(false, DefaultError);
                }
                return(request);
            }

            if (callback != null)
            {
                request.manager = manager;
                request.manager.MessageReceived += request.OnMessageReceived;
                request.manager.Connection.ConnectionStateChanged += request.OnConnectionStateChanged;
                request.timer    = timer;
                request.callback = callback;
            }
            manager.Send(new ProtocolMessage(ProtocolMessage.MessageAction.Heartbeat), null);
            if (callback != null)
            {
                request.timer.Start(HeartbeatTimeout, request.OnTimeout);
            }

            return(request);
        }
コード例 #2
0
        private void OnTransportMessageReceived(ProtocolMessage message)
        {
            Logger.Debug("ConnectionManager: Message Received {0}", message);

            bool handled = this.state.OnMessageReceived(message);

            handled |= this.ackProcessor.OnMessageReceived(message);
            handled |= ConnectionHeartbeatRequest.CanHandleMessage(message);

            if (message.ConnectionSerial != null)
            {
                this.connection.Serial = message.ConnectionSerial.Value;
            }

            if (this.MessageReceived != null)
            {
                this.MessageReceived(message);
            }
        }
コード例 #3
0
 public void Ping(Action <bool, ErrorInfo> callback)
 {
     ConnectionHeartbeatRequest.Execute(this, callback);
 }