public void Eio4Connected()
        {
            var msg = new ConnectedMessage
            {
                Eio = 4
            };
            string text = msg.Write();

            Assert.AreEqual("40", text);
        }
        public void Eio4NamespaceConnected()
        {
            var msg = new ConnectedMessage
            {
                Eio       = 4,
                Namespace = "/microsoft"
            };
            string text = msg.Write();

            Assert.AreEqual("40/microsoft,", text);
        }
        public void Eio3WsWithoutQueryConnected()
        {
            var msg = new ConnectedMessage
            {
                Eio       = 3,
                Protocol  = TransportProtocol.WebSocket,
                Namespace = "/admin"
            };
            string text = msg.Write();

            Assert.AreEqual("40/admin,", text);
        }
Exemplo n.º 4
0
        protected virtual async Task OpenAsync(OpenedMessage msg)
        {
            OpenedMessage = msg;
            var connectMsg = new ConnectedMessage
            {
                Namespace = Namespace,
                Eio       = EIO,
                Query     = Options.Query
            };

            for (int i = 1; i <= 3; i++)
            {
                try
                {
                    await SendAsync(connectMsg.Write(), CancellationToken.None).ConfigureAwait(false);

                    break;
                }
                catch (Exception e)
                {
                    if (i == 3)
                    {
                        Trace.TraceError(e.ToString());
                    }
                    else
                    {
                        await Task.Delay(TimeSpan.FromMilliseconds(Math.Pow(2, i) * 100));
                    }
                }
            }

            /*
             * try
             * {
             *  await Policy
             *     .Handle<Exception>()
             *     .WaitAndRetryAsync(3, attempt => TimeSpan.FromMilliseconds(Math.Pow(2, attempt) * 100))
             *     .ExecuteAsync(async () =>
             *     {
             *         await SendAsync(connectMsg.Write(), CancellationToken.None).ConfigureAwait(false);
             *     }).ConfigureAwait(false);
             *
             * }
             * catch (Exception e)
             * {
             *  Trace.TraceError(e.ToString());
             *  OnTransportClosed();
             * }
             */
        }
        public void Eio3WsWith1ParamConnected()
        {
            var msg = new ConnectedMessage
            {
                Eio       = 3,
                Protocol  = TransportProtocol.WebSocket,
                Namespace = "/apple",
                Query     = new Dictionary <string, string>
                {
                    { "a", "123" }
                }
            };
            string text = msg.Write();

            Assert.AreEqual("40/apple?a=123,", text);
        }
        public void Eio3WsWith2ParamConnected()
        {
            var msg = new ConnectedMessage
            {
                Eio       = 3,
                Protocol  = TransportProtocol.WebSocket,
                Namespace = "/razer",
                Query     = new Dictionary <string, string>
                {
                    { "a", "123" },
                    { "token", "qwer" }
                }
            };
            string text = msg.Write();

            Assert.AreEqual("40/razer?a=123&token=qwer,", text);
        }