Ejemplo n.º 1
0
        public void Open(string uri, string protocol, ClientAccessPolicyProtocol policyProtocol, bool enableAutoSendPing, int autoSendPingInterval)
        {
            m_AsyncOper = AsyncOperationManager.CreateOperation(null);

            //pass in Origin
            var hostName = HtmlPage.Document.DocumentUri.Host;
            var port = HtmlPage.Document.DocumentUri.Port;

            string origin = hostName;

            if (port != 80)
                origin += ":" + port;

            m_WebSocket = new WebSocket(uri, protocol, cookies: HtmlPage.Document.Cookies, origin: origin);
            m_WebSocket.Opened += new EventHandler(m_WebSocket_Opened);
            m_WebSocket.Closed += new EventHandler(m_WebSocket_Closed);
            m_WebSocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(m_WebSocket_MessageReceived);
            m_WebSocket.Error += new EventHandler<ErrorEventArgs>(m_WebSocket_Error);
            m_WebSocket.ClientAccessPolicyProtocol = (policyProtocol == ClientAccessPolicyProtocol.Http) ? SocketClientAccessPolicyProtocol.Http : SocketClientAccessPolicyProtocol.Tcp;
            m_WebSocket.EnableAutoSendPing = enableAutoSendPing;
            m_WebSocket.AutoSendPingInterval = autoSendPingInterval;
            m_WebSocket.Open();
        }
Ejemplo n.º 2
0
 public void Open(string uri, string protocol, ClientAccessPolicyProtocol policyProtocol, bool enableAutoSendPing)
 {
     Open(uri, protocol, policyProtocol, enableAutoSendPing, m_DefaultAutoSendPingInterval);
 }
Ejemplo n.º 3
0
 public void Open(string uri, string protocol, ClientAccessPolicyProtocol policyProtocol)
 {
     Open(uri, protocol, policyProtocol, true, m_DefaultAutoSendPingInterval);
 }