Ejemplo n.º 1
0
        public static void OnCharacterJoined(CharacterJoinedCommand characterJoinedCommand, IClientContext clientContext)
        {
            if (clientContext.Token != null)
                return;

            ((ClientContext)clientContext).Token = characterJoinedCommand.Token;
        }
Ejemplo n.º 2
0
 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;
     }
 }