예제 #1
0
 public Manager(Uri uri, Options opts)
 {
     if (opts == null)
     {
         opts = new Options();
     }
     if (opts.Path == null)
     {
         opts.Path = "/socket.io";
     }
     this.Opts = opts;
     this.Nsps = ImmutableDictionary.Create<string, Socket>();
     this.Subs = new Queue<On.IHandle>();
     this.Reconnection(opts.Reconnection);
     this.ReconnectionAttempts(opts.ReconnectionAttempts != 0 ? opts.ReconnectionAttempts : int.MaxValue);
     this.ReconnectionDelay(opts.ReconnectionDelay != 0 ? opts.ReconnectionDelay : 1000);
     this.ReconnectionDelayMax(opts.ReconnectionDelayMax != 0 ? opts.ReconnectionDelayMax : 5000);
     this.Timeout(opts.Timeout < 0 ? 20000 : opts.Timeout);
     this.ReadyState = ReadyStateEnum.CLOSED;
     this.Uri = uri;
     this.Connected = 0;
     this.Attempts = 0;
     this.Encoding = false;
     this.PacketBuffer = new List<Parser.Packet>();
     this.Encoder = new Parser.Parser.Encoder();
     this.Decoder = new Parser.Parser.Decoder();
     this.AutoConnect = opts.AutoConnect;
     if (AutoConnect)
     {
         Open();
     }
 }
예제 #2
0
        public static Socket Socket(Uri uri, Options opts)
        {

            var log = LogManager.GetLogger(Global.CallerName());
            if (opts == null)
            {
                opts = new Options();
            }

            Manager io;

            if (opts.ForceNew || !opts.Multiplex)
            {
                log.Info(string.Format("ignoring socket cache for {0}", uri.ToString()));
                io = new Manager(uri, opts);
            }
            else
            {
                var id = Url.ExtractId(uri);
                if (!Managers.ContainsKey(id))
                {
                    log.Info( string.Format("new io instance for {0}", id));
                    Managers.TryAdd(id, new Manager(uri, opts));

                }
                io = Managers[id];
            }
            return io.Socket(uri.PathAndQuery);
        }
예제 #3
0
        public Manager(Options opts) : this(null, opts)
        {

        }
예제 #4
0
        public Engine(Uri uri, Options opts) : base(uri, opts)
        {

        }
예제 #5
0
 public static Socket Socket(string uri, Options opts)
 {
     return Socket(Url.Parse(uri), opts);
 }