コード例 #1
0
ファイル: CommandHandlers.cs プロジェクト: kalantyr/Parallel
        public static void OnCharacterJoined(CharacterJoinedCommand characterJoinedCommand, IClientContext clientContext)
        {
            if (clientContext.Token != null)
                return;

            ((ClientContext)clientContext).Token = characterJoinedCommand.Token;
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: kalantyr/Parallel
 public static CommandBase Parse(byte[] data)
 {
     using (var stream = new MemoryStream(data))
     using (var reader = new BinaryReader(stream))
     {
         CommandBase command;
         switch ((CommandType)reader.ReadUInt16())
         {
             case CommandType.JoinCharacter:
                 command = new JoinCharacterCommand();
                 break;
             case CommandType.CharacterJoined:
                 command = new CharacterJoinedCommand();
                 break;
             case CommandType.CharacterDetected:
                 command = new CharacterDetectedCommand();
                 break;
             case CommandType.KeyPressed:
                 command = new KeyPressedCommand();
                 break;
             case CommandType.PositionChanged:
                 command = new PositionChangedCommand();
                 break;
             default:
                 throw new NotImplementedException();
         }
         command.Token = reader.ReadUInt16();
         command.Deserialize(reader);
         return command;
     }
 }