本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例7: ProtocolProcessorBase
public ProtocolProcessorBase(WebSocketVersion version, ICloseStatusCode closeStatusCode)
{
CloseStatusCode = closeStatusCode;
Version = version;
VersionTag = ((int)version).ToString();
}
示例8: ConnectWebSocket
public IPhotonPeer ConnectWebSocket(string ipAddress, ushort port, WebSocketVersion version, string url, string subProtocols, object userData)
{
throw new NotImplementedException();
}
示例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)
{
}
示例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;
}
示例11: WebSocketClientTest
protected WebSocketClientTest(WebSocketVersion version, string security, string certificateFile, string password)
{
m_Version = version;
m_Security = security;
m_CertificateFile = certificateFile;
m_Password = password;
}
示例12: Client
public Client(string url, WebSocketVersion socketVersion)
: this(url, WebSocketVersion.Rfc6455, null)
{
}
示例13: WebSocket
public WebSocket(string uri, string subProtocol, List<KeyValuePair<string, string>> cookies, string userAgent, WebSocketVersion version)
: this(uri, subProtocol, cookies, null, userAgent, version)
{
}
示例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);
}
示例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);
}