Beispiel #1
0
 void LolProxy_AcknowledgeMessageReceived(object sender, RemotingMessageReceivedEventArgs args)
 {
     if (args.Destination == "loginService" && args.Operation == "login")
     {
         AccountSummary = ((dynamic)args.Result.Body).accountSummary;
     }
     else if (args.Destination=="clientFacadeService"&&args.Operation=="getLoginDataPacketForUser")
     {
         Summoner = ((dynamic)args.Result.Body).allSummonerData.summoner;
     }
 }
Beispiel #2
0
 void ServerMessageReceived(object sender, RemotingMessageReceivedEventArgs e)
 {
     if (ClientMessageReceived != null)
     {
         ClientMessageReceived(sender, e);
         if (e.ReturnRequired)
         {
             RtmpClient client = (RtmpClient)sender;
             client.InvokeResult(e.InvokeId, e.MessageId, e.Data);
         }
     }
 }
 void OnRemotingMessageReceived(object sender, RemotingMessageReceivedEventArgs args)
 {
     RemoteProcedureCallEventArgs rpc = new RemoteProcedureCallEventArgs(args.Destination, args.Operation, (dynamic)args.Message.Body);
     _extensionManager.FireRemoteProcedureCallEvent(rpc);
     args.Message.Body = rpc.Parameters;
 }
 void OnErrorMessageReceived(object sender, RemotingMessageReceivedEventArgs args)
 {
     RemoteProcedureCallResponseEventArgs rpc = new RemoteProcedureCallResponseEventArgs(args.Destination, args.Operation, (dynamic[])args.Message.Body, args.Error == null ? null : args.Error.RootCause);
     _extensionManager.FireErrorMessageReceivedEvent(rpc);
     if (args.Error != null)
         args.Error.RootCause = rpc.ResponseBody;
 }
 void OnAckMessageReceived(object sender, RemotingMessageReceivedEventArgs args)
 {
     RemoteProcedureCallResponseEventArgs rpc = new RemoteProcedureCallResponseEventArgs(args.Destination, args.Operation, (dynamic)args.Message.Body, args.Result.Body);
     _extensionManager.FireAcknowledgeMessageReceivedEvent(rpc);
     args.Result.Body = rpc.ResponseBody;
 }
 private void OnRemotingMessageReceived(object sender, RemotingMessageReceivedEventArgs e)
 {
     try
     {
         if (RemotingMessageReceived != null)
             RemotingMessageReceived(this, e);
         e.Result = _remote.InvokeAckAsync(e.InvokeId, e.Message).Result;
         //TODO it's probably better to copy the eventargs
         if (AcknowledgeMessageReceived != null)
             AcknowledgeMessageReceived(this, e);
     }
     catch (AggregateException ex)
     {
         var exception = ex.InnerException as InvocationException;
         if (exception != null)
         {
             e.Error = (ErrorMessage) exception.SourceException;
             if (ErrorMessageReceived != null)
                 ErrorMessageReceived(this, e);
         }
         else 
             throw;
     }
 }
        async void EventReceivedCallback(object sender, EventReceivedEventArgs e)
        {
            try
            {
                switch (e.Event.MessageType)
                {
                    case MessageType.UserControlMessage:
                        var m = (UserControlMessage)e.Event;
                        if (m.EventType == UserControlMessageType.PingRequest)
                            WriteProtocolControlMessage(new UserControlMessage(UserControlMessageType.PingResponse, m.Values));
                        break;

                    case MessageType.DataAmf3:
#if DEBUG
                        // Have no idea what the contents of these packets are.
                        // Study these packets if we receive them.
                        System.Diagnostics.Debugger.Break();
#endif
                        break;
                    case MessageType.CommandAmf3:
                    case MessageType.DataAmf0:
                    case MessageType.CommandAmf0:
                        var command = (Command)e.Event;
                        var call = command.MethodCall;

                        var param = call.Parameters.Length == 1 ? call.Parameters[0] : call.Parameters;
                        if (call.Name == "_result"||call.Name == "_error"||call.Name == "receive")
                        {
                            //should not happen here
                            throw new InvalidDataException();
                        }
                        else if (call.Name == "onstatus")
                        {
                            System.Diagnostics.Debug.Print("Received status.");
                        }
                        else if (call.Name == "connect")
                        {
                            var message = (CommandMessage)call.Parameters[3];
                            object endpoint;
                            message.Headers.TryGetValue(AsyncMessageHeaders.Endpoint, out endpoint);
                            object id;
                            message.Headers.TryGetValue(AsyncMessageHeaders.ID, out id);
                            //ClientId = (string) id;

                            var args = new ConnectMessageEventArgs((string) call.Parameters[1], (string) call.Parameters[2], message, (string) endpoint, (string) id, command.InvokeId, (AsObject)command.ConnectionParameters);
                            if(ConnectMessageReceived!=null)
                                ConnectMessageReceived(this, args);
                            if(message.Operation==CommandOperation.ClientPing)
                                await InvokeConnectResultAsync(command.InvokeId, (AsObject)args.Result.Body);
                            else
                                await InvokeReconnectResultInvokeAsync(command.InvokeId, (AsObject)args.Result.Body);
                        }
                        else if (param is RemotingMessage)
                        {
                            var message = param as RemotingMessage;

                            object endpoint;
                            message.Headers.TryGetValue(AsyncMessageHeaders.Endpoint, out endpoint);
                            object id;
                            message.Headers.TryGetValue(AsyncMessageHeaders.ID, out id);

                            var args = new RemotingMessageReceivedEventArgs(message, (string) endpoint, (string) id, command.InvokeId);
                            if (RemotingMessageReceived != null)
                                RemotingMessageReceived(this, args);
                            if (args.Error == null)
                                InvokeResult(command.InvokeId, args.Result);
                            else
                                InvokeError(command.InvokeId, args.Error);

                        }
                        else if (param is CommandMessage)
                        {
                            var message = param as CommandMessage;

                            object endpoint;
                            message.Headers.TryGetValue(AsyncMessageHeaders.Endpoint, out endpoint);
                            object id;
                            message.Headers.TryGetValue(AsyncMessageHeaders.ID, out id);

                            var args = new CommandMessageReceivedEventArgs(message, endpoint as string, id as string, command.InvokeId);
                            if (CommandMessageReceived != null)
                                CommandMessageReceived(this, args);
                            InvokeResult(command.InvokeId, args.Result);
                        }
                        else
                        {
#if DEBUG
                            System.Diagnostics.Debug.Print("Unknown RTMP Command: " + call.Name);
                            System.Diagnostics.Debugger.Break();
#endif
                        }
                        break;
                }
            }
            catch(ClientDisconnectedException ex)
            {
                //Close();
            }
        }