Created
August 25, 2017 23:05
-
-
Save rogeralsing/08248846a908c70f3f2018eaf6dc149e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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