示例#1
0
                void IListener.Call(params object[] args)
                {
                    if (this._onTransportOpenListener.Parameters.Failed[0])
                    {
                        return;
                    }
                    LogManager log    = LogManager.GetLogger(Global.CallerName("", 0, ""));
                    Packet     packet = (Packet)args[0];

                    if (Packet.PONG == packet.Type && "probe" == (string)packet.Data)
                    {
                        this._onTransportOpenListener.Parameters.Socket.Upgrading = true;
                        this._onTransportOpenListener.Parameters.Socket.Emit(Socket.EVENT_UPGRADING,
                                                                             (object)this._onTransportOpenListener.Parameters.Transport[0]);
                        Socket.PriorWebsocketSuccess = WebSocket.NAME == this._onTransportOpenListener.Parameters.Transport[0].Name;
                        ((Polling)this._onTransportOpenListener.Parameters.Socket.mTransport).Pause((ActionTrigger)(() => {
                            if (this._onTransportOpenListener.Parameters.Failed[0] ||
                                (Socket.ReadyStateEnum.CLOSED == this._onTransportOpenListener.Parameters.Socket.ReadyState ||
                                 Socket.ReadyStateEnum.CLOSING == this._onTransportOpenListener.Parameters.Socket.ReadyState))
                            {
                                return;
                            }
                            log.Info("changing transport and sending upgrade packet");
                            this._onTransportOpenListener.Parameters.Cleanup[0]();
                            this._onTransportOpenListener.Parameters.Socket.SetTransport(this._onTransportOpenListener.Parameters
                                                                                         .Transport[0]);
                            ImmutableList <Packet> packets = ImmutableList <Packet> .Empty.Add(new Packet(Packet.UPGRADE));
                            try {
                                this._onTransportOpenListener.Parameters.Transport[0].Send(packets);
                                this._onTransportOpenListener.Parameters.Socket.Upgrading = false;
                                this._onTransportOpenListener.Parameters.Socket.Flush();
                                this._onTransportOpenListener.Parameters.Socket.Emit(Socket.EVENT_UPGRADE,
                                                                                     (object)this._onTransportOpenListener.Parameters.Transport[0]);
                                this._onTransportOpenListener.Parameters.Transport =
                                    this._onTransportOpenListener.Parameters.Transport.RemoveAt(0);
                            } catch (Exception ex) {
                                log.Error("", ex);
                            }
                        }));
                    }
                    else
                    {
                        log.Info(string.Format("probe transport '{0}' failed",
                                               (object)this._onTransportOpenListener.Parameters.Transport[0].Name));
                        EngineIOException engineIoException = new EngineIOException("probe error");
                        this._onTransportOpenListener.Parameters.Socket.Emit(Socket.EVENT_UPGRADE_ERROR,
                                                                             (object)engineIoException);
                    }
                }
示例#2
0
            void IListener.Call(params object[] args)
            {
                object            obj = args[0];
                EngineIOException engineIoException = !(obj is Exception)
          ? (!(obj is string)
            ? new EngineIOException("probe error")
            : new EngineIOException("probe error: " + (string)obj))
          : new EngineIOException("probe error", (Exception)obj);

                engineIoException.Transport = this._transport[0].Name;
                this._freezeTransport.Call();
                LogManager.GetLogger(Global.CallerName("", 0, "")).Info(string.Format(
                                                                            "probe transport \"{0}\" failed because of error: {1}", (object)engineIoException.Transport, obj));
                this._socket.Emit(Socket.EVENT_UPGRADE_ERROR, (object)engineIoException);
            }