Exemple #1
0
        //constructor(endPoint, opts = {}){
        //  this.stateChangeCallbacks = {open: [], close: [], error: [], message: []}
        //  this.channels             = []
        //  this.sendBuffer           = []
        //  this.ref                  = 0
        //  this.timeout              = opts.timeout || DEFAULT_TIMEOUT
        //  this.transport            = opts.transport || window.WebSocket || LongPoll
        //  this.heartbeatIntervalMs  = opts.heartbeatIntervalMs || 30000
        //  this.reconnectAfterMs     = opts.reconnectAfterMs || function(tries){
        //    return [1000, 2000, 5000, 10000][tries - 1] || 10000
        //  }
        //  this.logger               = opts.logger || function(){} // noop
        //  this.longpollerTimeout    = opts.longpollerTimeout || 20000
        //  this.params               = opts.params || {}
        //  this.endPoint             = `${endPoint}/${TRANSPORTS.websocket}`
        //  this.reconnectTimer       = new Timer(() => {
        //    this.disconnect(() => this.connect())
        //  }, this.reconnectAfterMs)
        //}

        public Socket(string endpoint, SocketOptions options) :
            this(endpoint,
                 options.Timeout.HasValue ? options.Timeout.Value : Phoenix.DEFAULT_TIMEOUT,
                 options.HeartbeatIntervalMs.HasValue ? options.HeartbeatIntervalMs.Value : Phoenix.DEFAULT_HEARTBEAT_INTERVAL,
                 options.Params,
                 options.ReconnectAfterMsCallback,
                 options.LogCallback
                 )
        {
        }
Exemple #2
0
    //constructor(endPoint, opts = {}){
    //  this.stateChangeCallbacks = {open: [], close: [], error: [], message: []}
    //  this.channels             = []
    //  this.sendBuffer           = []
    //  this.ref                  = 0
    //  this.timeout              = opts.timeout || DEFAULT_TIMEOUT
    //  this.transport            = opts.transport || window.WebSocket || LongPoll
    //  this.heartbeatIntervalMs  = opts.heartbeatIntervalMs || 30000
    //  this.reconnectAfterMs     = opts.reconnectAfterMs || function(tries){
    //    return [1000, 2000, 5000, 10000][tries - 1] || 10000
    //  }
    //  this.logger               = opts.logger || function(){} // noop
    //  this.longpollerTimeout    = opts.longpollerTimeout || 20000
    //  this.params               = opts.params || {}
    //  this.endPoint             = `${endPoint}/${TRANSPORTS.websocket}`
    //  this.reconnectTimer       = new Timer(() => {
    //    this.disconnect(() => this.connect())
    //  }, this.reconnectAfterMs)
    //}

    public Socket(string endpoint, SocketOptions options) :
      this(endpoint,
        options.Timeout.HasValue ? options.Timeout.Value : Phoenix.DEFAULT_TIMEOUT,
        options.HeartbeatIntervalMs.HasValue ? options.HeartbeatIntervalMs.Value : Phoenix.DEFAULT_HEARTBEAT_INTERVAL,
        options.Params,
        options.ReconnectAfterMsCallback,
        options.LogCallback
      )
    { }