Exemplo n.º 1
0
        public void RtmpConn_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            try {
                if (CurrentQueue != null && CurrentQueue.HandleMessage(e))
                {
                    return;
                }

                if (CurrentLobby != null && CurrentLobby.HandleMessage(e))
                {
                    return;
                }
            } catch (Exception x) {
                ThrowException(x, "Exception while dispatching message");
            }

            var response  = e.Body as LcdsServiceProxyResponse;
            var config    = e.Body as ClientDynamicConfigurationNotification;
            var invite    = e.Body as InvitationRequest;
            var endofgame = e.Body as EndOfGameStats;

            try {
                if (response != null)
                {
                    if (response.status.Equals("ACK"))
                    {
                        Log($"Acknowledged call of method {response.methodName} [{response.messageId}]");
                    }
                    else if (response.messageId != null && RiotServices.Delegates.ContainsKey(response.messageId))
                    {
                        RiotServices.Delegates[response.messageId](response);
                        RiotServices.Delegates.Remove(response.messageId);
                    }
                    else
                    {
                        Log($"Unhandled LCDS response of method {response.methodName} [{response.messageId}], {response.payload}");
                    }
                }
                else if (config != null)
                {
                    Log("Received Configuration Notification");
                }
                else if (invite != null)
                {
                    ShowInvite(invite);
                }
                else if (endofgame != null)
                {
                    //TODO End of game
                }
                else
                {
                    Log($"Receive [{e.Subtopic}, {e.ClientId}]: '{e.Body}'");
                }
            } catch (Exception x) {
                ThrowException(x, "Exception while handling message");
            }
        }