/// <summary> /// Uses HMQ Protocol and accepts TCP connections. /// </summary> public static IHorseServer UseHmq(this IHorseServer server, IProtocolConnectionHandler <HorseServerSocket, HorseMessage> handler) { HorseMqProtocol protocol = new HorseMqProtocol(server, handler); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses HMQ Protocol and accepts TCP connections. /// </summary> public static IHorseServer UseHmq(this IHorseServer server, HorseMessageHandler action) { HorseMethodHandler handler = new HorseMethodHandler(action); HorseMqProtocol protocol = new HorseMqProtocol(server, handler); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses HTTP Protocol and accepts HTTP connections with Horse MVC Architecture /// </summary> public static IHorseServer UseMvc(this IHorseServer server, HorseMvc mvc, HttpOptions options) { MvcConnectionHandler handler = new MvcConnectionHandler(mvc, mvc.AppBuilder); HorseHttpProtocol protocol = new HorseHttpProtocol(server, handler, options); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses HTTP Protocol and accepts HTTP connections /// </summary> public static IHorseServer UseHttp(this IHorseServer server, HttpRequestHandler action, string optionsFilename) { HttpMethodHandler handler = new HttpMethodHandler(action); HorseHttpProtocol protocol = new HorseHttpProtocol(server, handler, HttpOptions.Load(optionsFilename)); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses HTTP Protocol and accepts HTTP connections /// </summary> public static IHorseServer UseHttp(this IHorseServer server, HttpRequestHandler action, HttpOptions options) { HttpMethodHandler handler = new HttpMethodHandler(action); HorseHttpProtocol protocol = new HorseHttpProtocol(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 IHorseServer UseWebSockets(this IHorseServer server, IProtocolConnectionHandler <WsServerSocket, WebSocketMessage> handler, HttpOptions options) { //we need http protocol is added IHorseProtocol http = server.FindProtocol("http"); if (http == null) { HorseHttpProtocol httpProtocol = new HorseHttpProtocol(server, new WebSocketHttpHandler(), options); server.UseProtocol(httpProtocol); } HorseWebSocketProtocol protocol = new HorseWebSocketProtocol(server, handler); server.UseProtocol(protocol); return(server); }
/// <summary> /// Uses websocket protocol /// </summary> public static IHorseServer AddWebSockets(this IHorseServer server, HttpOptions options, Action <WebSocketServerBuilder> cfg) { //we need http protocol is added IHorseProtocol http = server.FindProtocol("http"); if (http == null) { HorseHttpProtocol httpProtocol = new HorseHttpProtocol(server, new WebSocketHttpHandler(), options); server.UseProtocol(httpProtocol); } WebSocketServerBuilder builder = new WebSocketServerBuilder(); cfg(builder); ModelWsConnectionHandler handler = builder.Build(); HorseWebSocketProtocol protocol = new HorseWebSocketProtocol(server, handler); server.UseProtocol(protocol); return(server); }