Skip to content

Instantly share code, notes, and snippets.

@georgechond94
Last active February 20, 2016 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgechond94/378bcb9d9670501898c4 to your computer and use it in GitHub Desktop.
Save georgechond94/378bcb9d9670501898c4 to your computer and use it in GitHub Desktop.
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
SignalR();
}
public void SignalR()
{
conn = new HubConnection("http://<your-mobile-app>.azurewebsites.net");
proxy = conn.CreateHubProxy("ChatHub");
conn.Start();
proxy.On<ChatMessage>("broadcastMessage", OnMessage);
}
public void Broadcast(ChatMessage msg)
{
proxy.Invoke("Send", msg);
}
private async void OnMessage(ChatMessage msg)
{
await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
ChatVM.Messages.Add(msg);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment