/// <summary> /// Uses HTTP Protocol and accepts HTTP connections with Twino MVC Architecture /// </summary> public static ITwinoServer UseMvc(this ITwinoServer server, TwinoMvc mvc, HttpOptions options) { MvcConnectionHandler handler = new MvcConnectionHandler(mvc, mvc.AppBuilder); TwinoHttpProtocol protocol = new TwinoHttpProtocol(server, handler, options); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses WebSocket Protocol and accepts HTTP connections which comes with "Upgrade: websocket" header data /// </summary> public static ITwinoServer UseWebSockets(this ITwinoServer server, IProtocolConnectionHandler <WsServerSocket, WebSocketMessage> handler, HttpOptions options) { //we need http protocol is added ITwinoProtocol http = server.FindProtocol("http"); if (http == null) { TwinoHttpProtocol httpProtocol = new TwinoHttpProtocol(server, new WebSocketHttpHandler(), options); server.UseProtocol(httpProtocol); } TwinoWebSocketProtocol protocol = new TwinoWebSocketProtocol(server, handler); server.UseProtocol(protocol); return(server); }