示例#1
0
        private void InternalServerMessageReceived(object sender, TcpMessageReceivedEventArgs e)
        {
            string message = Encoding.GetString(e.Message.GetMessage());

            ClientMessage clientMessage = _clientMessageParser.ParseFromJson(message);

            MidgeCommandInvoker commandInvoker = _controllerFactory.Create(clientMessage);

            commandInvoker.InvokeAsync(
                new MidgeContext(e.TcpClient, UsersManager, AudioBroadcaster), ServiceManager,
                (controller) =>
            {
                if (controller.Response == null)
                {
                    return;
                }

                var response = _serverMessageParser.Parse(controller.Response, clientMessage.Key);

                e.TcpClient.SendMessage(new TcpMessage(response.ToString()));
            }, (controller, exception) =>
            {
                var response = _serverMessageParser.ParseError(exception.Message, clientMessage.Key);

                e.TcpClient.SendMessage(new TcpMessage(response.ToString()));
            });
        }
 // TODO: Optionally add callback methods for async calls to the service agent
 private void HandleFeedback(object sender, TcpMessageReceivedEventArgs args)
 {
     ReloadTopPlayers();
     SetTopPlayers();
 }