private void Probe(string name) { LogManager.GetLogger(Global.CallerName("", 0, "")) .Info(string.Format("Probe probing transport '{0}'", (object)name)); Socket.PriorWebsocketSuccess = false; Transport transport = this.CreateTransport(name); Socket.ProbeParameters parameters = new Socket.ProbeParameters() { Transport = ImmutableList <Transport> .Empty.Add(transport), Failed = ImmutableList <bool> .Empty.Add(false), Cleanup = ImmutableList <ActionTrigger> .Empty, Socket = this }; Socket.OnTransportOpenListener onTransportOpen = new Socket.OnTransportOpenListener(parameters); Socket.FreezeTransportListener freezeTransport = new Socket.FreezeTransportListener(parameters); Socket.ProbingOnErrorListener onError = new Socket.ProbingOnErrorListener(this, parameters.Transport, (IListener)freezeTransport); Socket.ProbingOnTransportCloseListener onTransportClose = new Socket.ProbingOnTransportCloseListener(onError); Socket.ProbingOnCloseListener onClose = new Socket.ProbingOnCloseListener(onError); Socket.ProbingOnUpgradeListener onUpgrade = new Socket.ProbingOnUpgradeListener(freezeTransport, parameters.Transport); parameters.Cleanup = parameters.Cleanup.Add((ActionTrigger)(() => { if (parameters.Transport.Count < 1) { return; } parameters.Transport[0].Off(Transport.EVENT_OPEN, (IListener)onTransportOpen); parameters.Transport[0].Off(Transport.EVENT_ERROR, (IListener)onError); parameters.Transport[0].Off(Transport.EVENT_CLOSE, (IListener)onTransportClose); this.Off(Socket.EVENT_CLOSE, (IListener)onClose); this.Off(Socket.EVENT_UPGRADING, (IListener)onUpgrade); })); parameters.Transport[0].Once(Transport.EVENT_OPEN, (IListener)onTransportOpen); parameters.Transport[0].Once(Transport.EVENT_ERROR, (IListener)onError); parameters.Transport[0].Once(Transport.EVENT_CLOSE, (IListener)onTransportClose); this.Once(Socket.EVENT_CLOSE, (IListener)onClose); this.Once(Socket.EVENT_UPGRADING, (IListener)onUpgrade); parameters.Transport[0].Open(); }
public FreezeTransportListener(Socket.ProbeParameters parameters) { this.Parameters = parameters; }
public OnTransportOpenListener(Socket.ProbeParameters parameters) { this.Parameters = parameters; }