当前位置: 首页>>代码示例>>C#>>正文


C# WebSocketVersion类代码示例

本文整理汇总了C#中WebSocketVersion的典型用法代码示例。如果您正苦于以下问题:C# WebSocketVersion类的具体用法?C# WebSocketVersion怎么用?C# WebSocketVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebSocketVersion类属于命名空间,在下文中一共展示了WebSocketVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WebSocket

        public WebSocket(string uri, string subProtocol = "", string cookies = "", List<KeyValuePair<string, string>> customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None)
        {
            List<KeyValuePair<string, string>> cookieList = null;

            if (!string.IsNullOrEmpty(cookies))
            {
                cookieList = new List<KeyValuePair<string, string>>();

                string[] pairs = cookies.Split(';');

                int pos;
                string key, value;

                foreach (var p in pairs)
                {
                    pos = p.IndexOf('=');
                    if (pos > 0)
                    {
                        key = p.Substring(0, pos).Trim();
                        pos += 1;
                        if (pos < p.Length)
                            value = p.Substring(pos).Trim();
                        else
                            value = string.Empty;

                        cookieList.Add(new KeyValuePair<string, string>(key, Uri.UnescapeDataString(value)));
                    }
                }
            }

            Initialize(uri, subProtocol, cookieList, customHeaderItems, userAgent, origin, version);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:32,代码来源:WebSocket.Silverlight.cs

示例2: WebSocket

        public WebSocket(string uri, string subProtocol = "", List<KeyValuePair<string, string>> cookies = null, List<KeyValuePair<string, string>> customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None, EndPoint httpConnectProxy = null, SslProtocols sslProtocols = SslProtocols.None)
        {
#if !NETFX_CORE
            if (sslProtocols != SslProtocols.None)
                m_SecureProtocols = sslProtocols;
#endif

            Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy);
        }
开发者ID:theoxuan,项目名称:WebSocket4Net,代码行数:9,代码来源:WebSocket.Net.cs

示例3: Client

        public Client(string url, WebSocketVersion socketVersion)
        {
            this.uri = new Uri(url);

            this.socketVersion = socketVersion;

            this.registrationManager = new RegistrationManager();
            this.outboundQueue = new BlockingCollection<string>(new ConcurrentQueue<string>());
            this.dequeuOutBoundMsgTask = Task.Factory.StartNew(() => dequeuOutboundMessages(), TaskCreationOptions.LongRunning);
        }
开发者ID:OptimusLime,项目名称:IESoR,代码行数:10,代码来源:Client.cs

示例4: WebsocketClient

        public WebsocketClient(string url, string protocol, string userName, string userPassword, EndPoint httpProxy = null)
        {
            this.url = url;
            this.protocol = protocol;
            this.version = WebSocketVersion.Rfc6455;
            this.httpProxy = httpProxy;
            // http auth
            this.authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(userName + ":" + userPassword));

            init();
        }
开发者ID:rmartony,项目名称:previewdemo,代码行数:11,代码来源:WebsocketClient.cs

示例5: Setup

        public void Setup(string url, string protocol, WebSocketVersion version)
        {
            this.url = url;
            this.protocol = protocol;
            this.version = WebSocketVersion.Rfc6455;

            websocketClient = new WebSocket(this.url, this.protocol, this.version);

            websocketClient.Error               += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocketClient_Error);
            websocketClient.Opened              += new EventHandler(websocketClient_Opened);
            websocketClient.MessageReceived     += new EventHandler<MessageReceivedEventArgs>(websocketClient_MessageReceived);
        }
开发者ID:jamesdesouza,项目名称:WebSocketsDemo,代码行数:12,代码来源:Client.cs

示例6: CreateClient

        protected WebSocket4Net.WebSocket CreateClient(WebSocketVersion version, bool autoConnect)
        {
            var webSocketClient = new WebSocket4Net.WebSocket(string.Format("ws://127.0.0.1:{0}/websocket", AppServer.Config.Port), "basic", version);
            webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
            webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
            webSocketClient.DataReceived += new EventHandler<DataReceivedEventArgs>(webSocketClient_DataReceived);
            webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);

            if (autoConnect)
            {
                webSocketClient.Open();

                if (!OpenedEvent.WaitOne(1000))
                    Assert.Fail("Failed to open");
            }
            
            return webSocketClient;
        }
开发者ID:RocChing,项目名称:SuperSocket,代码行数:18,代码来源:WebSocketTestBase.cs

示例7: ProtocolProcessorBase

 public ProtocolProcessorBase(WebSocketVersion version, ICloseStatusCode closeStatusCode)
 {
     CloseStatusCode = closeStatusCode;
     Version = version;
     VersionTag = ((int)version).ToString();
 }
开发者ID:huguojunsy,项目名称:WebSocket4Net,代码行数:6,代码来源:ProtocolProcessorBase.cs

示例8: ConnectWebSocket

 public IPhotonPeer ConnectWebSocket(string ipAddress, ushort port, WebSocketVersion version, string url, string subProtocols, object userData)
 {
     throw new NotImplementedException();
 }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:4,代码来源:DummyApplicationSink.cs

示例9: WebSocket

 public WebSocket(string uri, string subProtocol = "", List<KeyValuePair<string, string>> cookies = null, List<KeyValuePair<string, string>> customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None, SslProtocols sslProtocols = SslProtocols.Default)
     : this(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, null, sslProtocols)
 {
 }
开发者ID:jchapuis,项目名称:WebSocket4Net,代码行数:4,代码来源:WebSocket.Net.cs

示例10: Initialize

        private void Initialize(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, List<KeyValuePair<string, string>> customHeaderItems, string userAgent, string origin, WebSocketVersion version)
        {
            if (version == WebSocketVersion.None)
            {
                NotSpecifiedVersion = true;
                version = WebSocketVersion.Rfc6455;
            }

            Version = version;
            ProtocolProcessor = GetProtocolProcessor(version);

            Cookies = cookies;

            Origin = origin;

            if (!string.IsNullOrEmpty(userAgent))
            {
                if (customHeaderItems == null)
                    customHeaderItems = new List<KeyValuePair<string, string>>();

                customHeaderItems.Add(new KeyValuePair<string, string>(UserAgentKey, userAgent));
            }

            if (customHeaderItems != null && customHeaderItems.Count > 0)
                CustomHeaderItems = customHeaderItems;

            var handshakeCmd = new Command.Handshake();
            m_CommandDict.Add(handshakeCmd.Name, handshakeCmd);
            var textCmd = new Command.Text();
            m_CommandDict.Add(textCmd.Name, textCmd);
            var dataCmd = new Command.Binary();
            m_CommandDict.Add(dataCmd.Name, dataCmd);
            var closeCmd = new Command.Close();
            m_CommandDict.Add(closeCmd.Name, closeCmd);
            var pingCmd = new Command.Ping();
            m_CommandDict.Add(pingCmd.Name, pingCmd);
            var pongCmd = new Command.Pong();
            m_CommandDict.Add(pongCmd.Name, pongCmd);
            var badRequestCmd = new Command.BadRequest();
            m_CommandDict.Add(badRequestCmd.Name, badRequestCmd);

            m_StateCode = WebSocketStateConst.None;

            SubProtocol = subProtocol;

            Items = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);

            TcpClientSession client;

            if (uri.StartsWith(m_UriPrefix, StringComparison.OrdinalIgnoreCase))
            {
                client = CreateClient(uri);
            }
            else if (uri.StartsWith(m_SecureUriPrefix, StringComparison.OrdinalIgnoreCase))
            {
                client = CreateSecureClient(uri);
            }
            else
            {
                throw new ArgumentException("Invalid uri", "uri");
            }

            client.Connected += new EventHandler(client_Connected);
            client.Closed += new EventHandler(client_Closed);
            client.Error += new EventHandler<ErrorEventArgs>(client_Error);
            client.DataReceived += new EventHandler<DataEventArgs>(client_DataReceived);

            Client = client;

            //Ping auto sending is enabled by default
            EnableAutoSendPing = true;
        }
开发者ID:screws0ft,项目名称:WebSocket4Net,代码行数:72,代码来源:WebSocket.cs

示例11: WebSocketClientTest

 protected WebSocketClientTest(WebSocketVersion version, string security, string certificateFile, string password)
 {
     m_Version = version;
     m_Security = security;
     m_CertificateFile = certificateFile;
     m_Password = password;
 }
开发者ID:kengoemon,项目名称:WebSocket4Net,代码行数:7,代码来源:WebSocketClientTest.cs

示例12: Client

		public Client(string url, WebSocketVersion socketVersion)
			: this(url, WebSocketVersion.Rfc6455, null)
		{
		}
开发者ID:hwj383,项目名称:SocketEvent.NET,代码行数:4,代码来源:Client.cs

示例13: WebSocket

        public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, string userAgent, WebSocketVersion version)
            : this(uri, subProtocol, cookies, null, userAgent, version)
        {

        }
开发者ID:kengoemon,项目名称:WebSocket4Net,代码行数:5,代码来源:WebSocket.Net35.cs

示例14: WebSocket

 public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, List<KeyValuePair<string, string>> customHeaderItems, string userAgent, string origin, WebSocketVersion version, EndPoint httpConnectProxy, System.Security.Authentication.SslProtocols sslProtocols)
 {
     m_SecureProtocols = sslProtocols;
     Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy);
 }
开发者ID:theoxuan,项目名称:WebSocket4Net,代码行数:5,代码来源:WebSocket.Net35.cs

示例15: WebSocket

 public WebSocket(string uri, string subProtocol = "", List<KeyValuePair<string, string>> cookies = null, List<KeyValuePair<string, string>> customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None, EndPoint httpConnectProxy = null, int receiveBufferSize = 0)
 {
     Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy, receiveBufferSize);
 }
开发者ID:kerryjiang,项目名称:WebSocket4Net,代码行数:4,代码来源:WebSocket.Silverlight.cs


注:本文中的WebSocketVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。