Exemple #1
0
        public DashingModule()
            : base()
        {
            Settings.DefaultDashboard = "sample";
            Settings.Views            = "dashboards";

            Get["/"] = x =>
            {
                return(Response.AsRedirect("/" + Settings.DefaultDashboard));
            };

            Get["/{dashboard}"] = p =>
            {
                return(View["dashboards/" + p.dashboard]);
            };

            Get["/views/{widget}.html"] = param =>
            {
                string widget = param.widget;
                return(Response.AsFile(string.Format("widgets/{0}/{0}.html", widget)));
            };

            Get["/events"] = param =>
            {
                var @event         = new { id = "Open", data = "Open" };
                var streamResponse = new EventStreamWriterResponse(Response, null, @event);
                ClientBus.Register(streamResponse);
                return(streamResponse);
            };

            Post["/widgets/{id}"] = p =>
            {
                Request.Body.Position = 0;
                var s    = new JavaScriptSerializer();
                var body = s.DeserializeObject(new StreamReader(Request.Body).ReadToEnd()).ToExpando();
                ClientBus.SendEvent(new Event
                {
                    Id        = p.id,
                    Data      = body,
                    UpdatedAt = SystemTime.Now()
                });
                return(200);
            };
        }
Exemple #2
0
        public DashingModule()
            : base()
        {
            Settings.DefaultDashboard = "sample";
            Settings.Views = "dashboards";

            Get["/"] = x =>
            {
                return Response.AsRedirect("/" + Settings.DefaultDashboard);
            };

            Get["/{dashboard}"] = p =>
            {
                return View["dashboards/" + p.dashboard];
            };

            Get["/views/{widget}.html"] = param =>
            {
                string widget = param.widget;
                return Response.AsFile(string.Format("widgets/{0}/{0}.html", widget));
            };

            Get["/events"] = param =>
            {
                var @event = new { id = "Open", data = "Open" };
                var streamResponse = new EventStreamWriterResponse(Response, null, @event);
                ClientBus.Register(streamResponse);
                return streamResponse;
            };

            Post["/widgets/{id}"] = p =>
                {
                    Request.Body.Position = 0;
                    var s = new JavaScriptSerializer();
                    var body = s.DeserializeObject(new StreamReader(Request.Body).ReadToEnd()).ToExpando();
                    ClientBus.SendEvent(new Event
                    {
                        Id = p.id,
                        Data = body,
                        UpdatedAt = SystemTime.Now()
                    });
                    return 200;
                };
        }
Exemple #3
0
 public static void Disconnect(EventStreamWriterResponse client)
 {
     Clients.Remove(client);
 }
Exemple #4
0
 public static void Register(EventStreamWriterResponse client)
 {
     Clients.Add(client);
 }
Exemple #5
0
 public static void Disconnect(EventStreamWriterResponse client)
 {
     Clients.Remove(client);
 }
Exemple #6
0
 public static void Register(EventStreamWriterResponse client)
 {
     Clients.Add(client);
 }