コード例 #1
0
        protected override void OnReceivedCommand(Command command)
        {
            //TODO generate events on command received

            command.SenderConnection = this;

            switch (command.CommandName)
            {
            case CommandName.State:
                Console.WriteLine("Command State");
                StateCommandReceived.Invoke(this, new SimpleEventArgs <StateCommand> {
                    Value = (StateCommand)command
                });
                break;

            case CommandName.Diff:
                Console.WriteLine("Command Diff");
                DiffCommandReceived.Invoke(this, new SimpleEventArgs <DiffCommand> {
                    Value = (DiffCommand)command
                });
                break;

            case CommandName.Participants:
                Console.WriteLine("Command Participants");
                ParticipantsCommandReceived.Invoke(this, new SimpleEventArgs <ParticipantsCommand> {
                    Value = (ParticipantsCommand)command
                });
                break;

            case CommandName.Input:
                Console.WriteLine("Command Input");
                InputCommandReceived.Invoke(this, new SimpleEventArgs <InputCommand>((InputCommand)command));
                break;

            case CommandName.PaintAddFigure:
                Console.WriteLine("Command PaintAddFigure");
                PaintAddFigureCommandRecieved.Invoke(this, new SimpleEventArgs <PaintAddFigureCommand> {
                    Value = (PaintAddFigureCommand)command
                });
                break;

            case CommandName.PaintDeleteFigure:
                Console.WriteLine("Command PaintDeleteFigure");
                PaintDeleteFigureCommandRecieved.Invoke(this, new SimpleEventArgs <PaintDeleteFigureCommand> {
                    Value = (PaintDeleteFigureCommand)command
                });
                break;

            case CommandName.RequestControl:
                Console.WriteLine("Command RequestControl");
                RequestControlCommandReceived.Invoke(this, new SimpleEventArgs <RequestControlCommand> {
                    Value = (RequestControlCommand)command
                });
                break;

            case CommandName.ControlAccess:
                Console.WriteLine("Command ControlAccess");
                ControlAccessCommandReceived.Invoke(this, new SimpleEventArgs <ControlAccessCommand> {
                    Value = (ControlAccessCommand)command
                });
                break;

            default:
                Console.WriteLine("Unknown command");
                break;
            }
        }
コード例 #2
0
 private static void ServerWebSocketConnectionOnRequestControllCommandReceived(object sender, SimpleEventArgs <RequestControlCommand> simpleEventArgs)
 {
     RequestControlCommandReceived.Invoke(sender, simpleEventArgs);
 }