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); }
public WebSocketClient(string uri, string subProtocol, WebSocketVersion version) : base(uri, subProtocol, version) { }
protected WebSocketClientTest(WebSocketVersion version, string security, string certificateFile, string password) { m_Version = version; m_Security = security; m_CertificateFile = certificateFile; m_Password = password; }
// Token: 0x060005EF RID: 1519 RVA: 0x00019CA4 File Offset: 0x00017EA4 public ProtocolProcessorBase(WebSocketVersion version, ICloseStatusCode closeStatusCode) { this.CloseStatusCode = closeStatusCode; this.Version = version; int num = (int)version; this.VersionTag = num.ToString(); }
protected DraftHybi10Processor( WebSocketVersion version, ICloseStatusCode closeStatusCode, string originHeaderName) : base(version, closeStatusCode) { this.m_OriginHeaderName = originHeaderName; }
public WebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, WebSocketVersion version) : this(uri, subProtocol, cookies, new List <KeyValuePair <string, string> >(), (string)null, version) { }
public WebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, string userAgent, WebSocketVersion version) : this(uri, subProtocol, cookies, (List <KeyValuePair <string, string> >)null, userAgent, version) { }
public JsonWebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, WebSocketVersion version) : this(uri, subProtocol, cookies, (List <KeyValuePair <string, string> >)null, string.Empty, string.Empty, version) { }
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); }
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); }
public WebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, WebSocketVersion version) : this(uri, subProtocol, cookies, customHeaderItems, userAgent, string.Empty, version) { }
// Token: 0x0600052A RID: 1322 RVA: 0x00005336 File Offset: 0x00003536 private static IProtocolProcessor GetProtocolProcessor(WebSocketVersion version) { IProtocolProcessor processorByVersion = WebSocket.m_ProtocolProcessorFactory.GetProcessorByVersion(version); if (processorByVersion == null) { throw new ArgumentException("Invalid websocket version"); } return(processorByVersion); }
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); }
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); //play short tone on connection websocketClient.MessageReceived += new EventHandler <MessageReceivedEventArgs>(websocketClient_MessageReceived); }
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(); }
public WebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, string origin, WebSocketVersion version) : this(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, (EndPoint)null) { }
public void Init() { this.url = "ws://mylive.in.th:9004/home/websocket/"; this.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); Aston.Log("WebSocket initiated."); }
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); }
public WebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, string origin, WebSocketVersion version, EndPoint httpConnectProxy) { this.Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy); }
public void Setup() { msgsList = new List <Message>(); this.url = "ws://" + Properties.Settings.Default.Host.ToString() + ":8081"; this.protocol = "basic"; this.version = WebSocketVersion.Rfc6455; websocketClient = new WebSocket(this.url, this.protocol, this.version); websocketClient.Error += new EventHandler <ErrorEventArgs>(WebsocketClient_Error); websocketClient.Opened += new EventHandler(WebsocketClient_Opened); websocketClient.MessageReceived += new EventHandler <MessageReceivedEventArgs>(WebsocketClient_MessageReceived); }
public JsonWebSocket( string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, string origin, WebSocketVersion version) { this.m_WebSocket = new WebSocket(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version); this.m_WebSocket.EnableAutoSendPing = true; this.SubscribeEvents(); }
public WebSocketClient(string uri, string subProtocol = "", List <KeyValuePair <string, string> > cookies = null, List <KeyValuePair <string, string> > customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None) : base(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version) { }
public MyClient(string uri, string protocol) { this.url = uri; this.protocol = protocol; this.version = WebSocketVersion.Rfc6455; this.Active = false; //this.timer1 = new Timer(new TimerCallback(TickTimer1),null,1000,3000); webSocket = new WebSocket(this.url, this.protocol, this.version); webSocket.AutoSendPingInterval = 2000; webSocket.Closed += WebSocket_Closed; webSocket.DataReceived += WebSocket_DataReceived; webSocket.Error += new EventHandler <SuperSocket.ClientEngine.ErrorEventArgs>(WebSocket_Error); webSocket.Opened += WebSocket_Opened; webSocket.MessageReceived += WebSocket_MessageReceived; }
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; }
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); }
private void Initialize(string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, string origin, WebSocketVersion version, EndPoint httpConnectProxy, int receiveBufferSize) { 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); m_HttpConnectProxy = httpConnectProxy; TcpClientSession client; if (uri.StartsWith(m_UriPrefix, StringComparison.OrdinalIgnoreCase)) { client = CreateClient(uri, receiveBufferSize); } else if (uri.StartsWith(m_SecureUriPrefix, StringComparison.OrdinalIgnoreCase)) { #if !NETFX_CORE client = CreateSecureClient(uri, receiveBufferSize); #else throw new NotSupportedException("WebSocket4Net still has not supported secure websocket for UWP yet."); #endif } 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; }
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.Default) { Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy, sslProtocols); }
protected WebSocketClientTest(WebSocketVersion version) : this(version, string.Empty, string.Empty, string.Empty) { }
public IPhotonPeer ConnectWebSocket(string ipAddress, ushort port, WebSocketVersion version, string url, string subProtocols, object userData) { throw new NotImplementedException(); }
public Client(string url, WebSocketVersion socketVersion) : this(url, WebSocketVersion.Rfc6455, null) { }
public WebSocket(string uri, string subProtocol, WebSocketVersion version) : this(uri, subProtocol, null, version) { }
public WebSocket(string uri, WebSocketVersion version) : this(uri, string.Empty, null, version) { }
public WebSocketRequestBuilder Version8() { this.version = WebSocketVersion.V08; return(this); }
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) { }
protected WebSocket CreateClient(WebSocketVersion version) { return CreateClient(version, true); }
public WebSocketClientTest(WebSocketVersion version) { m_Version = version; }
protected DraftHybi10Processor(WebSocketVersion version, ICloseStatusCode closeStatusCode) : base(version, closeStatusCode) { }
private static IProtocolProcessor GetProtocolProcessor(WebSocketVersion version) { var processor = m_ProtocolProcessorFactory.GetProcessorByVersion(version); if (processor == null) throw new ArgumentException("Invalid websocket version"); return processor; }
public WebSocket(string uri, string subProtocol, WebSocketVersion version) : this(uri, subProtocol, EmptyCookies, null, string.Empty, string.Empty, version) { }
public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, string userAgent, WebSocketVersion version) : this(uri, subProtocol, cookies, null, userAgent, version) { }
public WebSocketRequestBuilder Version00() { this.version = null; return(this); }
public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, List<KeyValuePair<string, string>> customHeaderItems, string userAgent, WebSocketVersion version) : this(uri, subProtocol, cookies, customHeaderItems, userAgent, string.Empty, version) { }
public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, List<KeyValuePair<string, string>> customHeaderItems, string userAgent, string origin, WebSocketVersion version, EndPoint httpConnectProxy) { Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy, SslProtocols.Default); }
public WebSocket(string uri, string subProtocol, List <KeyValuePair <string, string> > cookies, List <KeyValuePair <string, string> > customHeaderItems, string userAgent, string origin, WebSocketVersion version) { Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version); }
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) { Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version); }
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); }
public IProtocolProcessor GetProcessorByVersion(WebSocketVersion version) { return m_OrderedProcessors.FirstOrDefault(p => p.Version == version); }
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); }
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, int receiveBufferSize = 0) { if (sslProtocols != 0) { m_SecureProtocols = sslProtocols; } Initialize(uri, subProtocol, cookies, customHeaderItems, userAgent, origin, version, httpConnectProxy, receiveBufferSize); }
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; }
protected DraftHybi10Processor(WebSocketVersion version, ICloseStatusCode closeStatusCode, string originHeaderName) : base(version, closeStatusCode) { this.m_OriginHeaderName = originHeaderName; }
public ProtocolProcessorBase(WebSocketVersion version, ICloseStatusCode closeStatusCode) { CloseStatusCode = closeStatusCode; Version = version; VersionTag = ((int)version).ToString(); }
public WebSocket(string uri, string subProtocol, WebSocketVersion version, SslProtocols sslProtocols = SslProtocols.Default) : this(uri, subProtocol, EmptyCookies, null, string.Empty, string.Empty, version, sslProtocols) { }