private void HandleOnMessage(string message) { Report.GetWebSocketResponse(message); long messageId; MessageType messageType; ErrorCode errorCode = AwesomeFormat.ReadHeader(message, out messageType, out messageId); switch (messageType) { case MessageType.partyGetInvitedNotif: Lobby.HandleNotification(message, this.InvitedToParty); break; case MessageType.partyJoinNotif: Lobby.HandleNotification(message, this.JoinedParty); break; case MessageType.partyKickNotif: Lobby.HandleNotification(message, this.KickedFromParty); break; case MessageType.partyLeaveNotif: Lobby.HandleNotification(message, this.LeaveFromParty); break; case MessageType.personalChatNotif: Lobby.HandleNotification(message, this.PersonalChatReceived); break; case MessageType.partyChatNotif: Lobby.HandleNotification(message, this.PartyChatReceived); break; case MessageType.messageNotif: Lobby.HandleNotification(message, this.OnNotification); break; case MessageType.userStatusNotif: Lobby.HandleNotification(message, this.FriendsStatusChanged); break; case MessageType.matchmakingNotif: Lobby.HandleNotification(message, this.MatchmakingCompleted); break; case MessageType.dsNotif: Lobby.HandleNotification(message, this.DSUpdated); break; case MessageType.acceptFriendsNotif: Lobby.HandleNotification(message, this.FriendRequestAccepted); break; case MessageType.requestFriendsNotif: Lobby.HandleNotification(message, this.OnIncomingFriendRequest); break; case MessageType.setReadyConsentNotif: Lobby.HandleNotification(message, this.ReadyForMatchConfirmed); break; case MessageType.rematchmakingNotif: Lobby.HandleNotification(message, this.RematchmakingNotif); break; case MessageType.channelChatNotif: Lobby.HandleNotification(message, this.ChannelChatReceived); break; case MessageType.connectNotif: AwesomeFormat.ReadPayload(message, out lobbySessionId); break; case MessageType.disconnectNotif: Lobby.HandleNotification(message, this.Disconnecting); break; case MessageType.partyDataUpdateNotif: Lobby.HandleNotification(message, this.PartyDataUpdateNotif); break; case MessageType.partyRejectNotif: Lobby.HandleNotification(message, this.RejectedPartyInvitation); break; case MessageType.blockPlayerNotif: Lobby.HandleNotification(message, this.PlayerBlockedNotif); break; case MessageType.unblockPlayerNotif: Lobby.HandleNotification(message, this.PlayerUnblockedNotif); break; default: Action <ErrorCode, string> handler; if (messageId != -1 && this.responseCallbacks.TryGetValue(messageId, out handler)) { this.responseCallbacks.Remove(messageId); handler(errorCode, message); } break; } }
private void HandleMessages(object sender, MessageEventArgs eventArgs) { Debug.Log("HandleMessage: " + eventArgs.Data.ToString()); long messageId; MessageType messageType; ErrorCode errorCode = AwesomeFormat.ReadHeader(eventArgs.Data, out messageType, out messageId); switch (messageType) { case MessageType.partyGetInvitedNotif: Lobby.HandleNotification(eventArgs.Data, this.InvitedToParty); break; case MessageType.partyJoinNotif: Lobby.HandleNotification(eventArgs.Data, this.JoinedParty); break; case MessageType.partyKickNotif: Lobby.HandleNotification(eventArgs.Data, this.KickedFromParty); break; case MessageType.personalChatNotif: Lobby.HandleNotification(eventArgs.Data, this.PersonalChatReceived); break; case MessageType.partyChatNotif: Lobby.HandleNotification(eventArgs.Data, this.PartyChatReceived); break; case MessageType.messageNotif: Lobby.HandleNotification(eventArgs.Data, this.OnNotification); break; case MessageType.userStatusNotif: Lobby.HandleNotification(eventArgs.Data, this.UserStatusNotification); break; case MessageType.matchmakingNotif: Lobby.HandleNotification(eventArgs.Data, this.MatchmakingNotification); break; case MessageType.acceptFriendsNotif: Lobby.HandleNotification(eventArgs.Data, this.OnFriendRequestAccepted); break; case MessageType.requestFriendsNotif: Lobby.HandleNotification(eventArgs.Data, this.OnIncomingFriendRequest); break; case MessageType.connectNotif: this.Connected = true; break; default: Action <ErrorCode, string> handler; if (messageId != -1 && this.responseCallbacks.TryGetValue(messageId, out handler)) { this.responseCallbacks.Remove(messageId); handler(errorCode, eventArgs.Data); } break; } }