internal void StartTimeout() { // PhoenixJS: null check implicit CancelTimeout(); Ref = _channel.Socket.MakeRef(); _refEvent = Channel.ReplyEventName(Ref); var serializer = _channel.Socket.Opts.MessageSerializer; _channel.On(_refEvent, message => { CancelRefEvent(); CancelTimeout(); _receivedResp = serializer.MapReply(message.Payload); MatchReceive(_receivedResp); }); _delayedExecution = _channel.Socket.Opts.DelayedExecutor.Execute(() => { Trigger(ReplyStatus.Timeout); }, _timeout); }
//startTimeout(){ if(this.timeoutTimer){ return } // this.ref = this.channel.socket.makeRef() // this.refEvent = this.channel.replyEventName(this.ref) // this.channel.on(this.refEvent, payload => { // this.cancelRefEvent() // this.cancelTimeout() // this.receivedResp = payload // this.matchReceive(payload) // }) // this.timeoutTimer = setTimeout(() => { // this.trigger("timeout", {}) // }, this.timeout) //} internal void StartTimeout() { if (_timeoutTimer.Enabled) { return; //jfis - dont do if timer running } _ref = _channel.Socket.MakeRef(); //jfis - get new ref _refEvent = _channel.ReplyEventName(_ref); //jfis - ref as string _channel.On(_refEvent, (payload, _) => //make binding for refEvent { CancelRefEvent(); CancelTimeout(); var json = (JObject)payload; _receivedResp = json; MatchReceive(json); }); _timeoutTimer.Interval = _timeout; _timeoutTimer.Start(); //start timeout timer, which triggers "timeout" }