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); }
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); } }
public void Ping(Action <bool, ErrorInfo> callback) { ConnectionHeartbeatRequest.Execute(this, callback); }