void IListener.Call(params object[] args) { object err = args[0]; EngineIOException error; if (err is Exception) { error = new EngineIOException("probe error", (Exception)err); } else if (err is string) { error = new EngineIOException("probe error: " + (string)err); } else { error = new EngineIOException("probe error"); } error.Transport = _transport[0].Name; _freezeTransport.Call(); var log = LogManager.GetLogger(Global.CallerName()); log.Info(string.Format("probe transport \"{0}\" failed because of error: {1}", error.Transport, err)); _socket.Emit(EVENT_UPGRADE_ERROR, error); }
protected Transport OnError(string message, Exception exception) { Exception err = new EngineIOException(message, exception); this.Emit(EVENT_ERROR, err); return(this); }
public void OnPacket(Packet packet) { var log = LogManager.GetLogger(Global.CallerName()); if (ReadyState == ReadyStateEnum.OPENING || ReadyState == ReadyStateEnum.OPEN) { log.Info(string.Format("socket received: type '{0}', data '{1}'", packet.Type, packet.Data)); Emit(EVENT_PACKET, packet); Emit(EVENT_HEARTBEAT); if (packet.Type == Packet.OPEN) { OnHandshake(new HandshakeData((string)packet.Data)); } else if (packet.Type == Packet.PONG) { this.SetPing(); } else if (packet.Type == Packet.ERROR) { var err = new EngineIOException("server error") { code = packet.Data }; this.Emit(EVENT_ERROR, err); } else if (packet.Type == Packet.MESSAGE) { Emit(EVENT_DATA, packet.Data); Emit(EVENT_MESSAGE, packet.Data); } } else { log.Info(string.Format("OnPacket packet received with socket readyState '{0}'", ReadyState)); } }
void IListener.Call(params object[] args) { if (_onTransportOpenListener.Parameters.Failed[0]) { return; } var log = LogManager.GetLogger(Global.CallerName()); var msg = (Packet)args[0]; if (Packet.PONG == msg.Type && "probe" == (string)msg.Data) { //log.Info( // string.Format("probe transport '{0}' pong", // _onTransportOpenListener.Parameters.Transport[0].Name)); _onTransportOpenListener.Parameters.Socket.Upgrading = true; _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADING, _onTransportOpenListener.Parameters.Transport[0]); Socket.PriorWebsocketSuccess = WebSocket.NAME == _onTransportOpenListener.Parameters.Transport[0].Name; //log.Info( // string.Format("pausing current transport '{0}'", // _onTransportOpenListener.Parameters.Socket.Transport.Name)); ((Polling)_onTransportOpenListener.Parameters.Socket.Transport).Pause( () => { if (_onTransportOpenListener.Parameters.Failed[0]) { return; } if (ReadyStateEnum.CLOSED == _onTransportOpenListener.Parameters.Socket.ReadyState || ReadyStateEnum.CLOSING == _onTransportOpenListener.Parameters.Socket.ReadyState) { return; } log.Info("changing transport and sending upgrade packet"); _onTransportOpenListener.Parameters.Cleanup[0](); _onTransportOpenListener.Parameters.Socket.SetTransport( _onTransportOpenListener.Parameters.Transport[0]); ImmutableList <Packet> packetList = ImmutableList <Packet> .Empty.Add(new Packet(Packet.UPGRADE)); try { _onTransportOpenListener.Parameters.Transport[0].Send(packetList); _onTransportOpenListener.Parameters.Socket.Flush(); _onTransportOpenListener.Parameters.Socket.Upgrading = false; _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADE, _onTransportOpenListener.Parameters.Transport[0]); _onTransportOpenListener.Parameters.Transport = _onTransportOpenListener.Parameters.Transport.RemoveAt(0); } catch (Exception e) { log.Error("", e); } }); } else { log.Info(string.Format("probe transport '{0}' failed", _onTransportOpenListener.Parameters.Transport[0].Name)); var err = new EngineIOException("probe error"); _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADE_ERROR, err); } }
protected Transport OnError(string message, Exception exception) { Exception err = new EngineIOException(message, exception); this.Emit(EVENT_ERROR, err); return this; }
public void OnPacket(Packet packet) { var log = LogManager.GetLogger(Global.CallerName()); if (ReadyState == ReadyStateEnum.OPENING || ReadyState == ReadyStateEnum.OPEN) { log.Info(string.Format("socket received: type '{0}', data '{1}'", packet.Type, packet.Data)); Emit(EVENT_PACKET, packet); Emit(EVENT_HEARTBEAT); if (packet.Type == Packet.OPEN) { OnHandshake(new HandshakeData((string)packet.Data)); } else if (packet.Type == Packet.PONG) { this.SetPing(); } else if (packet.Type == Packet.ERROR) { var err = new EngineIOException("server error"); err.code = packet.Data; this.Emit(EVENT_ERROR, err); } else if (packet.Type == Packet.MESSAGE) { Emit(EVENT_DATA, packet.Data); Emit(EVENT_MESSAGE, packet.Data); } } else { log.Info(string.Format("OnPacket packet received with socket readyState '{0}'", ReadyState)); } }
void IListener.Call(params object[] args) { object err = args[0]; EngineIOException error; if (err is Exception) { error = new EngineIOException("probe error", (Exception)err); } else if (err is string) { error = new EngineIOException("probe error: " + (string)err); } else { error = new EngineIOException("probe error"); } error.Transport = _transport[0].Name; _freezeTransport.Call(); var log = LogManager.GetLogger(Global.CallerName()); log.Info(string.Format("probe transport \"{0}\" failed because of error: {1}", error.Transport, err)); _socket.Emit(EVENT_UPGRADE_ERROR, error); }
void IListener.Call(params object[] args) { if (_onTransportOpenListener.Parameters.Failed[0]) { return; } var log = LogManager.GetLogger(Global.CallerName()); var msg = (Packet) args[0]; if (Packet.PONG == msg.Type && "probe" == (string) msg.Data) { //log.Info( // string.Format("probe transport '{0}' pong", // _onTransportOpenListener.Parameters.Transport[0].Name)); _onTransportOpenListener.Parameters.Socket.Upgrading = true; _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADING, _onTransportOpenListener.Parameters.Transport[0]); Socket.PriorWebsocketSuccess = WebSocket.NAME == _onTransportOpenListener.Parameters.Transport[0].Name; //log.Info( // string.Format("pausing current transport '{0}'", // _onTransportOpenListener.Parameters.Socket.Transport.Name)); ((Polling) _onTransportOpenListener.Parameters.Socket.Transport).Pause( () => { if (_onTransportOpenListener.Parameters.Failed[0]) { return; } if (ReadyStateEnum.CLOSED == _onTransportOpenListener.Parameters.Socket.ReadyState || ReadyStateEnum.CLOSING == _onTransportOpenListener.Parameters.Socket.ReadyState) { return; } log.Info("changing transport and sending upgrade packet"); _onTransportOpenListener.Parameters.Cleanup[0](); _onTransportOpenListener.Parameters.Socket.SetTransport( _onTransportOpenListener.Parameters.Transport[0]); ImmutableList<Packet> packetList = ImmutableList<Packet>.Empty.Add(new Packet(Packet.UPGRADE)); try { _onTransportOpenListener.Parameters.Transport[0].Send(packetList); _onTransportOpenListener.Parameters.Socket.Flush(); _onTransportOpenListener.Parameters.Socket.Upgrading = false; _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADE, _onTransportOpenListener.Parameters.Transport[0]); _onTransportOpenListener.Parameters.Transport = _onTransportOpenListener.Parameters.Transport.RemoveAt(0); } catch (Exception e) { log.Error("",e); } }); } else { log.Info(string.Format("probe transport '{0}' failed", _onTransportOpenListener.Parameters.Transport[0].Name)); var err = new EngineIOException("probe error"); _onTransportOpenListener.Parameters.Socket.Emit(EVENT_UPGRADE_ERROR, err); } }