public WebSocketClientChannel(Uri endpointUri, WebSocketConfig config, CancellationToken token) { endpoint = endpointUri; this.config = config; this.token = token; Id = "ws-" + Guid.NewGuid().ToString(); sendQueue = new TaskQueue(); queue = new ConcurrentQueue <byte[]>(); }
public WebSocketServerChannel(HttpContext context, System.Net.WebSockets.WebSocket socket, WebSocketConfig config, CancellationToken token) { Id = "ws-" + Guid.NewGuid(); this.config = config; this.token = token; IsEncrypted = context.Request.Scheme == "wss"; IsAuthenticated = context.User.Identity.IsAuthenticated; handler = new WebSocketHandler(config, token); handler.OnReceive += Handler_OnReceive; handler.OnError += Handler_OnError; handler.OnOpen += Handler_OnOpen; handler.OnClose += Handler_OnClose; this.socket = socket; }
//public WebSocketServerChannel(HttpListenerWebSocketContext context, WebSocketConfig config, CancellationToken token) //{ // Id = "ws-" + Guid.NewGuid().ToString(); // this.token = token; // this.IsEncrypted = context.RequestUri.Scheme == "wss"; // this.IsAuthenticated = HttpHelper.HttpContext.User.Identity.IsAuthenticated; // this.handler = new WebSocketHandler(config, token); // this.handler.OnReceive += Handler_OnReceive; // this.handler.OnError += Handler_OnError; // this.handler.OnOpen += Handler_OnOpen; // this.handler.OnClose += Handler_OnClose; //} public WebSocketServerChannel(HttpContext context, WebSocketConfig config, CancellationToken token) { Id = "ws-" + Guid.NewGuid().ToString(); this.config = config; this.token = token; this.IsEncrypted = context.Request.Scheme == "wss"; this.IsAuthenticated = context.User.Identity.IsAuthenticated; this.handler = new WebSocketHandler(config, token); this.handler.OnReceive += Handler_OnReceive; this.handler.OnError += Handler_OnError; this.handler.OnOpen += Handler_OnOpen; this.handler.OnClose += Handler_OnClose; Task task = Task.Factory.StartNew(async() => { await Task.Delay(100); this.socket = await context.AcceptWebSocketRequestAsync(this.handler); }); Task.WhenAll(task); }
public static WebSocketChannel Create(Uri endpointUri, X509Certificate2 certificate, string subProtocol, WebSocketConfig config, CancellationToken token) { return(new WebSocketClientChannel(endpointUri, certificate, subProtocol, config, token)); }
public static WebSocketChannel Create(Uri endpointUri, string securityToken, string subProtocol, WebSocketConfig config, CancellationToken token) { return(new WebSocketClientChannel(endpointUri, securityToken, subProtocol, config, token)); }
public static WebSocketChannel Create(Uri endpointUri, WebSocketConfig config, CancellationToken token) { return(new WebSocketClientChannel(endpointUri, config, token)); }
public static WebSocketChannel Create(HttpContext context, System.Net.WebSockets.WebSocket socket, WebSocketConfig config, CancellationToken token) { return(new WebSocketServerChannel(context, socket, config, token)); }
public WebSocketHandler(WebSocketConfig config, CancellationToken token) { this.config = config; this.token = token; }
public WebSocketClientChannel(Uri endpointUri, X509Certificate2 certificate, string subProtocol, WebSocketConfig config, CancellationToken token) { endpoint = endpointUri; this.certificate = certificate; this.subProtocol = subProtocol; this.config = config; this.token = token; Id = "ws-" + Guid.NewGuid().ToString(); sendQueue = new TaskQueue(); queue = new ConcurrentQueue <byte[]>(); }