Esempio n. 1
0
        public static short GetPacketOpcode(MainWindow window, string name, bool isServer = true)
        {
            short opCode =
                (from val in isServer ? ServerPacketNames : ClientPacketNames
                 where val.Value.Equals(name)
                 select val.Key).FirstOrDefault();

            if (opCode == 0)
            {
                while (true)
                {
                    try
                    {
                        InputValueBox inputBox = new InputValueBox(window, "Need to enter opcode", "Enter " + name + " opcode: ");
                        if (inputBox.Show() == false)
                        {
                            return(0);
                        }

                        opCode = BitConverter.ToInt16(inputBox.Result.ToBytes(), 0);
                        break;
                    }
                    // ReSharper disable EmptyGeneralCatchClause
                    catch
                    // ReSharper restore EmptyGeneralCatchClause
                    {
                        MessageBox.Show("WRONG PARAMS!", "Error", 0, MessageBoxImage.Warning);
                    }
                }
            }

            return(opCode);
        }
Esempio n. 2
0
        public static short GetPacketOpcode(MainWindow window, string name, bool isServer = true)
        {
            short opCode =
                (from val in isServer ? ServerPacketNames : ClientPacketNames
                 where val.Value.Equals(name)
                 select val.Key).FirstOrDefault();

            if(opCode == 0)
            {
                while (true)
                {
                    try
                    {
                        InputValueBox inputBox = new InputValueBox(window, "Need to enter opcode", "Enter "+ name +" opcode: ");
                        if (inputBox.Show() == false)
                            return 0;

                        opCode = BitConverter.ToInt16(inputBox.Result.ToBytes(), 0);
                        break;
                    }
                    // ReSharper disable EmptyGeneralCatchClause
                    catch
                    // ReSharper restore EmptyGeneralCatchClause
                    {
                        MessageBox.Show("WRONG PARAMS!", "Error", 0, MessageBoxImage.Warning);
                    }
                }
            }

            return opCode;
        }