private void Upgrade(Reactor.Http.HttpContext context, Reactor.Action <Exception, Reactor.Web.Socket.Socket> callback) { var request = ServerWebSocketUpgradeRequest.Create(context); //-------------------------------------------------------- // if not a web socket attempt, defer to http callback. //-------------------------------------------------------- if (request == null) { this.servercb(context); return; } var response = ServerWebSocketUpgradeResponse.Create(request); var socket_context = new Reactor.Web.Socket.Context(context); this.OnUpgrade(socket_context, (success, reason) => { if (!success) { response.Reject(reason == null ? "" : reason, (exception) => callback(exception, null)); return; } response.Accept((exception) => { if (exception != null) { callback(exception, null); return; } var channel = new Transport(context.Connection); var socket = new Socket(channel); socket.Context = socket_context; callback(null, socket); }); }); }
private ServerWebSocketUpgradeResponse(ServerWebSocketUpgradeRequest request) { this.request = request; this.Headers = new Dictionary <string, string>(); }
public static ServerWebSocketUpgradeResponse Create(ServerWebSocketUpgradeRequest request) { return(new ServerWebSocketUpgradeResponse(request)); }
public static ServerWebSocketUpgradeResponse Create(ServerWebSocketUpgradeRequest request) { return new ServerWebSocketUpgradeResponse(request); }
private ServerWebSocketUpgradeResponse(ServerWebSocketUpgradeRequest request) { this.request = request; this.Headers = new Dictionary<string, string>(); }