Пример #1
0
        public EventModule()
        {
            Get["/"] = x => View["/events"];

            Get["/connect"] = x =>
            {
                var responseWriter = new EventStreamWriterResponse(Response, "Open", new { data = "connection is opened!" });
                Clients.Add(responseWriter);
                return(responseWriter);
            };

            Post["/event/{id}/{message}"] = p =>
            {
                Dispatch(writer => writer.Write(p.id, new { id = p.id, data = p.message }));
                return(200);
            };

            Post["/event/{message}"] = p =>
            {
                Dispatch(writer => writer.Write(null, new { data = p.message }));
                return(200);
            };
        }
Пример #2
0
        public EventModule()
        {
            Get["/"] = x => View["/events"];

            Get["/connect"] = x =>
            {
                var responseWriter = new EventStreamWriterResponse(Response, "Open", new { data = "connection is opened!" });
                Clients.Add(responseWriter);
                return responseWriter;
            };

            Post["/event/{id}/{message}"] = p =>
            {
                Dispatch(writer => writer.Write(p.id, new { id = p.id, data = p.message }));
                return 200;
            };

            Post["/event/{message}"] = p =>
                {
                    Dispatch(writer => writer.Write(null, new { data = p.message }));
                    return 200;
                };
        }