SetTimeout() 공개 메소드

public SetTimeout ( ) : void
리턴 void
예제 #1
0
 //rejoinUntilConnected(){
 //  this.rejoinTimer.setTimeout()
 //  if(this.socket.isConnected()){
 //    this.rejoin()
 //  }
 //}
 public void RejoinUntilConnected()
 {
     _socket.Log("timer", "chan rejoin");
     _rejoinTimer.SetTimeout();
     if (_socket.IsConnected()) //jfis - instead of checking, socket should tell channel
     {
         Rejoin();
     }
 }
예제 #2
0
파일: Socket.cs 프로젝트: namjae/dn-phoenix
        //onConnClose(event){
        //  this.log("transport", "close", event)
        //  this.triggerChanError()
        //  clearInterval(this.heartbeatTimer)
        //  this.reconnectTimer.setTimeout()
        //  this.stateChangeCallbacks.close.forEach( callback => callback(event) )
        //}
        internal void OnConnClose(object sender, CloseEventArgs e)
        {
            Log("transport", "close");

            TriggerChanError();           //jfis - trigger error event on all channels
            _heartbeatTimer.Stop();       //jfis - no conn so stop heartbeat
            _reconnectTimer.SetTimeout(); //jfis - no conn so start trying to reconnect

            foreach (var cb in _closeCallbacks)
            {
                cb(e.WasClean, e.Reason, e.Code);
            }
        }
예제 #3
0
파일: Channel.cs 프로젝트: jfis/dn-phoenix
    //constructor(topic, params, socket) {
    //  this.state       = CHANNEL_STATES.closed
    //  this.topic       = topic
    //  this.params      = params || {}
    //  this.socket      = socket
    //  this.bindings    = []
    //  this.timeout     = this.socket.timeout
    //  this.joinedOnce  = false
    //  this.joinPush    = new Push(this, CHANNEL_EVENTS.join, this.params, this.timeout)
    //  this.pushBuffer  = []
    //  this.rejoinTimer  = new Timer(
    //    () => this.rejoinUntilConnected(),
    //    this.socket.reconnectAfterMs
    //  )
    //  this.joinPush.receive("ok", () => {
    //    this.state = CHANNEL_STATES.joined
    //    this.rejoinTimer.reset()
    //    this.pushBuffer.forEach( pushEvent => pushEvent.send() )
    //    this.pushBuffer = []
    //  })
    //  this.onClose( () => {
    //    this.socket.log("channel", `close ${this.topic}`)
    //    this.state = CHANNEL_STATES.closed
    //    this.socket.remove(this)
    //  })
    //  this.onError( reason => {
    //    this.socket.log("channel", `error ${this.topic}`, reason)
    //    this.state = CHANNEL_STATES.errored
    //    this.rejoinTimer.setTimeout()
    //  })
    //  this.joinPush.receive("timeout", () => {
    //    if(this.state !== CHANNEL_STATES.joining){ return }

    //    this.socket.log("channel", `timeout ${this.topic}`, this.joinPush.timeout)
    //    this.state = CHANNEL_STATES.errored
    //    this.rejoinTimer.setTimeout()
    //  })
    //  this.on(CHANNEL_EVENTS.reply, (payload, ref) => {
    //    this.trigger(this.replyEventName(ref), payload)
    //  })
    //}
    public Channel(string topic, JObject params_, Socket socket)
    {
      _state = ChannelState.Closed;
      _topic = topic;
      _params = params_ ?? Phoenix.EMPTY_JS_OBJECT;
      _socket = socket;

      _bindings = new List<Binding>();
      _timeout = _socket.Timeout;
      _joinedOnce = false;
      _joinPush = new Push(this, Phoenix.CHANNEL_EVENT_JOIN, _params, _timeout);
      _pushBuffer = new List<Push>();

      _rejoinTimer = new RetryTimer(RejoinUntilConnected, _socket.ReconnectAfterMs); //jfis - why another timer instead of waiting for socket event?

      _joinPush.Receive("ok",
        (_) =>
        {
          _socket.Log("JP REC OK", "");
          _state = ChannelState.Joined;
          _rejoinTimer.Reset();
          foreach (var p in _pushBuffer) p.Send();
          _pushBuffer.Clear();
        }
      );

      OnClose(() =>
        {
          _socket.Log("channel", $"close {_topic}");

          _state = ChannelState.Closed;
          _socket.Remove(this);
        });

      OnError(
        () => //reason only used for logging
        {
          _socket.Log("channel", $"error {_topic}"); //, reason);

          _state = ChannelState.Errored;
          _rejoinTimer.SetTimeout();
        }
      );

      _joinPush.Receive("timeout",
        (_) =>
        {
          if (_state == ChannelState.Joining) return;

          _socket.Log("channel", $"timeout {_topic}");//, _joinPush.timeout)

          _state = ChannelState.Errored;
          _rejoinTimer.SetTimeout();
        }
      );

      On(Phoenix.CHANNEL_EVENT_REPLY, OnReply);
    }
예제 #4
0
        //constructor(topic, params, socket) {
        //  this.state       = CHANNEL_STATES.closed
        //  this.topic       = topic
        //  this.params      = params || {}
        //  this.socket      = socket
        //  this.bindings    = []
        //  this.timeout     = this.socket.timeout
        //  this.joinedOnce  = false
        //  this.joinPush    = new Push(this, CHANNEL_EVENTS.join, this.params, this.timeout)
        //  this.pushBuffer  = []
        //  this.rejoinTimer  = new Timer(
        //    () => this.rejoinUntilConnected(),
        //    this.socket.reconnectAfterMs
        //  )
        //  this.joinPush.receive("ok", () => {
        //    this.state = CHANNEL_STATES.joined
        //    this.rejoinTimer.reset()
        //    this.pushBuffer.forEach( pushEvent => pushEvent.send() )
        //    this.pushBuffer = []
        //  })
        //  this.onClose( () => {
        //    this.socket.log("channel", `close ${this.topic}`)
        //    this.state = CHANNEL_STATES.closed
        //    this.socket.remove(this)
        //  })
        //  this.onError( reason => {
        //    this.socket.log("channel", `error ${this.topic}`, reason)
        //    this.state = CHANNEL_STATES.errored
        //    this.rejoinTimer.setTimeout()
        //  })
        //  this.joinPush.receive("timeout", () => {
        //    if(this.state !== CHANNEL_STATES.joining){ return }

        //    this.socket.log("channel", `timeout ${this.topic}`, this.joinPush.timeout)
        //    this.state = CHANNEL_STATES.errored
        //    this.rejoinTimer.setTimeout()
        //  })
        //  this.on(CHANNEL_EVENTS.reply, (payload, ref) => {
        //    this.trigger(this.replyEventName(ref), payload)
        //  })
        //}
        public Channel(string topic, JObject params_, Socket socket)
        {
            _state  = ChannelState.Closed;
            _topic  = topic;
            _params = params_ ?? Phoenix.EMPTY_JS_OBJECT;
            _socket = socket;

            _bindings   = new List <Binding>();
            _timeout    = _socket.Timeout;
            _joinedOnce = false;
            _joinPush   = new Push(this, Phoenix.CHANNEL_EVENT_JOIN, _params, _timeout);
            _pushBuffer = new List <Push>();

            _rejoinTimer = new RetryTimer(RejoinUntilConnected, _socket.ReconnectAfterMs); //jfis - why another timer instead of waiting for socket event?

            _joinPush.Receive("ok",
                              (_) =>
            {
                _socket.Log("JP REC OK", "");
                _state = ChannelState.Joined;
                _rejoinTimer.Reset();
                foreach (var p in _pushBuffer)
                {
                    p.Send();
                }
                _pushBuffer.Clear();
            }
                              );

            OnClose(() =>
            {
                _socket.Log("channel", $"close {_topic}");

                _state = ChannelState.Closed;
                _socket.Remove(this);
            });

            OnError(
                () =>                                      //reason only used for logging
            {
                _socket.Log("channel", $"error {_topic}"); //, reason);

                _state = ChannelState.Errored;
                _rejoinTimer.SetTimeout();
            }
                );

            _joinPush.Receive("timeout",
                              (_) =>
            {
                if (_state == ChannelState.Joining)
                {
                    return;
                }

                _socket.Log("channel", $"timeout {_topic}");//, _joinPush.timeout)

                _state = ChannelState.Errored;
                _rejoinTimer.SetTimeout();
            }
                              );

            On(Phoenix.CHANNEL_EVENT_REPLY, OnReply);
        }