void IListener.Call(params object[] args) { var err = args[0]; PureEngineIOException error; if (err is Exception exception) { error = new PureEngineIOException("probe error", exception); } else if (err is string s) { error = new PureEngineIOException("probe error: " + s); } else { error = new PureEngineIOException("probe error"); } error.Transport = Transport[0].Name; FreezeTransport.Call(); Logger.Log(new Exception($"probe transport \"{error.Transport}\" failed because of error: {err}")); _socket.Emit(PureEngineIoSocket.EVENT_UPGRADE_ERROR, error); }
public void OnPacket(Packet packet) { if (ReadyState == ReadyStateEnum.OPENING || ReadyState == ReadyStateEnum.OPEN) { Logger.Log($"socket received: type '{packet.Type}', data '{packet.Data}'"); Emit(EVENT_PACKET, packet); Emit(EVENT_HEARTBEAT); if (packet.Type == Packet.OPEN) { OnHandshake(HandshakeData.FromString((string)packet.Data)); } else if (packet.Type == Packet.PONG) { SetPing(); } else if (packet.Type == Packet.ERROR) { var err = new PureEngineIOException("server error") { Code = packet.Data }; Emit(EVENT_ERROR, err); } else if (packet.Type == Packet.MESSAGE) { Emit(EVENT_DATA, packet.Data); Emit(EVENT_MESSAGE, packet.Data); } } else { Logger.Log($"OnPacket packet received with socket readyState '{ReadyState}'"); } }