Skip to content

Instantly share code, notes, and snippets.

@rogeralsing
Created August 25, 2017 23:05
Show Gist options
  • Save rogeralsing/08248846a908c70f3f2018eaf6dc149e to your computer and use it in GitHub Desktop.
Save rogeralsing/08248846a908c70f3f2018eaf6dc149e to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Pusher.ViewModels;
using Starcounter;
namespace Pusher
{
class Program
{
static void Main()
{
Application.Current.Use(new HtmlFromJsonProvider());
Application.Current.Use(new PartialToStandaloneHtmlProvider());
Schedule();
Handle.GET("/", () => new MainPage());
}
private static void Schedule()
{
Task.Run(async () =>
{
while (true)
{
await Task.Delay(1000);
Session.ForAll((s, i) =>
{
Push(s);
});
}
});
}
static void Push(Session session)
{
if (session.PublicViewModel is MainPage p)
{
p.time = DateTime.Now.ToString();
session.CalculatePatchAndPushOnWebSocket();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment