Exemplo n.º 1
0
        private Transport CreateTransport(string name)
        {
            var query = new Dictionary <string, string>(Query);

            query.Add("EIO", Parser.Parser.Protocol.ToString());
            query.Add("transport", name);
            if (Id != null)
            {
                query.Add("sid", Id);
            }
            var options = new Transport.Options
            {
                Hostname          = Hostname,
                Port              = Port,
                Proxy             = Proxy,
                Secure            = Secure,
                Path              = Path,
                Query             = query,
                TimestampRequests = TimestampRequests,
                TimestampParam    = TimestampParam,
                PolicyPort        = PolicyPort,
                Socket            = this,
                Agent             = this.Agent,
                ForceBase64       = this.ForceBase64,
                ForceJsonp        = this.ForceJsonp,
                Cookies           = this.Cookies,
                ExtraHeaders      = this.ExtraHeaders
            };

            if (name == WebSocket.NAME)
            {
                return(new WebSocket(options));
            }
            else if (name == Polling.NAME)
            {
                return(new PollingXHR(options));
            }

            throw new EngineIOException("CreateTransport failed");
        }
Exemplo n.º 2
0
        private Transport CreateTransport(string name)
        {
            var query = new Dictionary <string, string>(Query);

            query.Add("EIO", Parser.Parser.Protocol.ToString());
            query.Add("transport", name);
            if (Id != null)
            {
                query.Add("sid", Id);
            }
            var options = new Transport.Options();

            options.Hostname          = Hostname;
            options.Port              = Port;
            options.Secure            = Secure;
            options.SslProtocols      = SslProtocols;
            options.Path              = Path;
            options.Query             = query;
            options.TimestampRequests = TimestampRequests;
            options.TimestampParam    = TimestampParam;
            options.PolicyPort        = PolicyPort;
            options.Socket            = this;
            options.Agent             = this.Agent;
            options.ForceBase64       = this.ForceBase64;
            options.ForceJsonp        = this.ForceJsonp;
            options.Cookies           = this.Cookies;

            if (name == WebSocket.NAME)
            {
                return(new WebSocket(options));
            }
            else if (name == Polling.NAME)
            {
                return(new PollingXHR(options));
            }

            throw new EngineIOException("CreateTransport failed");
        }
Exemplo n.º 3
-2
        public void Uri()
        {
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
            log.Info("Start");

            var options = new Transport.Options();
            options.Path = "/engine.io";
            options.Hostname = this.CreateOptions().Hostname;
            options.Secure = false;
            options.Query = new Dictionary<string, string> {{"sid", "test"}};
            options.TimestampRequests = false;
            var polling = new Polling(options);
            var expected = string.Format("http://{0}/engine.io?sid=test&b64=1", options.Hostname);
            Assert.Contains(expected, polling.Uri());
        }
Exemplo n.º 4
-2
        public void TimestampedUri()
        {
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
            log.Info("Start");

            var options = new Transport.Options();
            options.Path = "/engine.io";
            options.Hostname = "test";
            options.Secure = false;
            options.Query = new Dictionary<string, string> {{"sid", "test"}};
            options.TimestampRequests = true;
            options.TimestampParam = "t";
            var polling = new Polling(options);

            string pat = @"http://test/engine.io\?sid=test&(t=[0-9]+-[0-9]+)";
            var r = new Regex(pat, RegexOptions.IgnoreCase);
            var test = polling.Uri();
            log.Info(test);
            Match m = r.Match(test);
            Assert.True(m.Success);
        }
Exemplo n.º 5
-2
        private Transport CreateTransport(string name)
        {
            var query = new Dictionary<string, string>(Query);
            query.Add("EIO", Parser.Parser.Protocol.ToString());
            query.Add("transport", name);
            if (Id != null)
            {
                query.Add("sid", Id);
            }
            var options = new Transport.Options();
            options.Hostname = Hostname;
            options.Port = Port;
            options.Secure = Secure;
            options.Path = Path;
            options.Query = query;
            options.TimestampRequests = TimestampRequests;
            options.TimestampParam = TimestampParam;
            options.PolicyPort = PolicyPort;
            options.Socket = this;
            options.Agent = this.Agent;
            options.ForceBase64 = this.ForceBase64;
            options.ForceJsonp = this.ForceJsonp;
            options.Cookies = this.Cookies;

            if (name == WebSocket.NAME)
            {
                return new WebSocket(options);
            }
            else if (name == Polling.NAME)
            {
                return new PollingXHR(options);
            }

            throw new EngineIOException("CreateTransport failed");
        }
Exemplo n.º 6
-2
        public void WsUri()
        {
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
            log.Info("Start");

            var options = new Transport.Options();
            options.Path = "/engine.io";
            options.Hostname = "test";
            options.Secure = false;
            options.Query = new Dictionary<string, string> {{"transport", "websocket"}};
            options.TimestampRequests = false;
            var ws = new WebSocket(options);
            Assert.Contains("ws://test/engine.io?transport=websocket", ws.Uri());
        }