Saves the private message
This commit is contained in:
parent
a789f5617c
commit
509ffafef8
1 changed files with 15 additions and 5 deletions
|
|
@ -241,24 +241,34 @@ namespace BookAStar
|
||||||
if (isConnected)
|
if (isConnected)
|
||||||
{
|
{
|
||||||
// TODO Start all cloud related stuff
|
// TODO Start all cloud related stuff
|
||||||
|
CurrentApp.StartHubConnection();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the Hub connection
|
// Start the Hub connection
|
||||||
private async void StartHubConnection ()
|
public async void StartHubConnection ()
|
||||||
{
|
{
|
||||||
|
if (chatHubConnection != null)
|
||||||
|
chatHubConnection.Dispose();
|
||||||
chatHubConnection = new HubConnection(Constants.SignalRHubsUrl);
|
chatHubConnection = new HubConnection(Constants.SignalRHubsUrl);
|
||||||
if (MainSettings.CurrentUser != null)
|
if (MainSettings.CurrentUser != null)
|
||||||
chatHubConnection.Headers.Add("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
|
chatHubConnection.Headers.Add("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
|
||||||
|
|
||||||
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
|
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
|
||||||
chatHubProxy.On<string, string>("AddMessage", (n, m) => {
|
chatHubProxy.On<string, string>("PV", (n, m) => {
|
||||||
Messages.Add(string.Format("{0} says: {1}", n, m));
|
DataManager.Current.PrivateMessages.Add(
|
||||||
|
new Model.Social.PrivateMessage
|
||||||
|
{
|
||||||
|
Message = m,
|
||||||
|
SenderId = n,
|
||||||
|
Date = DateTime.Now
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
await chatHubConnection.Start();
|
await chatHubConnection.Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
private HubConnection chatHubConnection=null;
|
private HubConnection chatHubConnection=null;
|
||||||
private IHubProxy chatHubProxy = null;
|
private IHubProxy chatHubProxy = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue