public async virtual void JoinChat(ChatClient phoneChatClient) { // Fire up SignalR Connection & join chatroom. try { await chatConnection.Start(); if (chatConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected) { await SignalRChatHub.Invoke("JoinChatroom", phoneChatClient); } } catch (Exception) { // Do some error handling. } // Listen to chat events on SignalR Server & wire them up appropriately. SignalRChatHub.On<string>("addChatMessage", message => { SignalREventArgs chatArgs = new SignalREventArgs(); chatArgs.ChatMessageFromServer = message; // Raise custom event & let it bubble up. SignalRServerNotification(this, chatArgs); }); }
public virtual void OnSignalRServerNotificationReceived(SignalREventArgs e) { if (SignalRServerNotification != null) { SignalRServerNotification(this, e); } }
public async virtual void StartObjectSync() { // Fire up SignalR Connection & start object sync. try { await objConnection.Start(); } catch (Exception) { // Do some error handling. } // Listen to object updates from SignalR Server & wire them up appropriately. SignalRObjSyncHub.On<CustomClass>("syncObject", customObject => { SignalREventArgs objSyncArgs = new SignalREventArgs(); objSyncArgs.CustomObject = customObject; // Raise custom event & let it bubble up. SignalRServerNotification(this, objSyncArgs); }); }
public async virtual void FollowLiveGame() { try { await gameConnection.Start(); } catch (Exception) { // Do some error handling. } // Listen to Game score updates from SignalR Server & wire them up appropriately. SignalRGameScoreHub.On<int, int>("pushScores", (teamAScore, teamBScore) => { SignalREventArgs gameScoreArgs = new SignalREventArgs(); gameScoreArgs.TeamAScore = teamAScore; gameScoreArgs.TeamBScore = teamBScore; // Raise custom event & let it bubble up. SignalRServerNotification(this, gameScoreArgs); }); }