Exemplo n.º 1
0
    private void RegisterCommandHandlers()
    {
        CommandExecutor.CommandHandler amplitude = args =>
        {
            var strands = (Strands)args[0];
            UpdateAmplitudeValue(strands.AverageValues());
        };
        m_Receiver.RegisterCommandHandler(CommandReceiver.AMPLITUDE, amplitude);

        CommandExecutor.CommandHandler exit = args =>
        {
            m_Client.Disconnect();
            Application.Quit();
        };
        m_Receiver.RegisterCommandHandler(CommandReceiver.EXIT, exit);

        CommandExecutor.CommandHandler reward = args =>
        {
            UpdateRewards();
        };
        m_Receiver.RegisterCommandHandler(CommandReceiver.REWARD, reward);

        CommandExecutor.CommandHandler threshold = args =>
        {
            var strands = (Strands)args[0];
            UpdateThresholdValue(strands.AverageValues());
        };
        m_Receiver.RegisterCommandHandler(CommandReceiver.THRESHOLD, threshold);
    }
        public static void HandleJoinMessage(SimpleClient client, JoinMessage message)
        {
            Character character = client.Account.Characters.FirstOrDefault(x => x.Id == message.characterId);

            if (character == null)
            {
                client.Disconnect();
                return;
            }

            client.Character        = character;
            client.Character.Client = client;

            Map map = WorldManager.Instance.GetMapById(character.Record.SceneId);

            if (map == null)
            {
                client.Disconnect();
                return;
            }

            client.Character.Position = new ObjectPosition(character.Record.X, character.Record.Y, character.Record.Z);

            map.Enter(client.Character);

            SendJoinRightMessage(client, message.characterId, character.Position.Map.SceneId, character.Position.X, character.Position.Y, character.Position.Z, false, 0);//Send all players in the map
            var stats = StatsFields.LoadInertieData();

            SendSnapshotMessage(client, new Snapshot[] { new SetStateVerSnapshot(1),
                                                         new UpdateServerTimeSnapshot(DateTime.UtcNow.GetUnixTimeStamp()),
                                                         new AddObjectSnapshot(client.Character.GetObjectType(true)),
                                                         new AddObjectSnapshot(new MonsterObjectType(ObjectTypeEnum.OT_MOB, (uint)client.GetHashCode(),
                                                                                                     20, 0xFFFFFFFF, 609, 300, 600, 0, 0, 100, "Nuan",
                                                                                                     stats.Count, stats.Keys.Select(x => (ushort)x).ToArray(),
                                                                                                     stats.Values.Select(x => x.Total).ToArray(), 0, new byte[0], new int[0], new int[0], 1,
                                                                                                     false, 255, 0, 0, 0, 0, new uint[0], 0, true, true, false, 0, 0, 2, -1, 0)) });
            foreach (var attribute in client.Character.Stats.Fields)
            {
                SendSnapshotMessage(client, new []
                {
                    new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)attribute.Key, attribute.Value.Total),
                });
            }
            List <Snapshot> spawnOtherObjects = new List <Snapshot>();

            foreach (var @object in map.Objects.Where(x => x != character))
            {
                spawnOtherObjects.Add(new AddObjectSnapshot(@object.GetObjectType()));
            }
            SendSnapshotMessage(client, spawnOtherObjects.ToArray());

            //foreach (var stats in client.Character.Stats.Fields)
            //{
            //    SendSnapshotMessage(client, new Snapshot[] { new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)stats.Key, (int)stats.Value.Total) });
            //}
        }
Exemplo n.º 3
0
        public static void HandleNS_CS_LOGIN(SimpleClient client, NS_CS_LOGIN message)
        {
            Account account = AccountManager.Instance.GetTicketAccount(message.sessionKey);

            if (account == null)
            {
                client.Disconnect();
                return;
            }

            client.Account = account;
            Character leader = client.Character.RoomConnected.PlayersConnected.FirstOrDefault(x => x.IsLeader);


            //client.Send(new NM_SC_LOGIN2());

            if (leader != null)
            {
                leader.RelayClient = client;
                client.Send(new NM_SC_LOGIN(leader.Client.IP, 5000));
            }
            else
            {
                client.Send(new NM_SC_LOGIN(SimpleServer.AuthHost, 5000));
            }
        }
Exemplo n.º 4
0
        public static void HandleBS_CS_CHARACTER_LIST(SimpleClient client, BS_CS_CHARACTER_LIST message)
        {
            if (client.Account.SessionKey != message.sessionKey)
            {
                client.Disconnect();
                return;
            }

            CharacterRecord character = CharacterManager.Instance.GetCharacterByAccountId(client.Account.Id);

            if (character == null)
            {
                client.Send(new BM_SC_CHARACTER_LIST("", 1, 0, new List <ListCharacterInfoType>()));
            }
            else
            {
                client.Account.Character = new Character(character, client);
                client.Send(new BM_SC_CHARACTER_LIST(client.Character.Name, 0, 1, new List <ListCharacterInfoType>()
                {
                    new ListCharacterInfoType(0, 0, 0)                                                                                                  /*, new ListCharacterInfoType(0, 1, 0), new ListCharacterInfoType(0, 2, 0), new ListCharacterInfoType(0, 3, 0), new ListCharacterInfoType(0, 4, 0), new ListCharacterInfoType(0, 5, 0) */
                }));
                Thread.Sleep(4000);
                client.Send(new BM_SC_CHARACTER_LIST2(client.Character.Name, (short)client.Character.Type, 6, new List <ListCharacterInfoType2>()
                {
                    new ListCharacterInfoType2(0, 0, 0), new ListCharacterInfoType2(1, 1, 1), new ListCharacterInfoType2(2, 2, 2), new ListCharacterInfoType2(3, 3, 3), new ListCharacterInfoType2(4, 4, 4), new ListCharacterInfoType2(5, 5, 5)
                }));
                //client.Send(new BM_SC_SELECT_CHARACTER());
            }
        }
Exemplo n.º 5
0
        public static void HandleBS_CS_LOGIN(SimpleClient client, BS_CS_LOGIN message)
        {
            if ((client.Account = AccountManager.Instance.GetTicketAccount(message.sessionKey)) != null)
            {
                //Thread.Sleep(7000);
                client.Send(new BM_SC_LOGIN((int)0, 999));
                //client.Send(new BM_SC_CHARACTER_TYPE_LIST(5, new List<CharacterTypeInfoType>() { new CharacterTypeInfoType(0, 1), new CharacterTypeInfoType(1, 2), new CharacterTypeInfoType(2, 2), new CharacterTypeInfoType(3, 1), new CharacterTypeInfoType(4, 2) }));

                //if (client.Account.SessionKey != message.sessionKey)
                //{
                //    client.Disconnect();
                //    return;
                //}

                //CharacterRecord character = CharacterManager.Instance.GetCharacterByAccountId(client.Account.Id);

                //if (character == null)
                //    client.Send(new BM_SC_CHARACTER_LIST("", 1, 0, new List<ListCharacterInfoType>()));
                //else
                //{
                //    client.Account.Character = new Character(character);
                //    client.Send(new BM_SC_CHARACTER_LIST(client.Character.Name, client.Character.Level, 1, new List<ListCharacterInfoType>() { client.Character.GetListCharacterInfoType() }));
                //    Thread.Sleep(4000);
                //    client.Send(new BM_SC_CHARACTER_LIST2(client.Character.Name, 1, 1, new List<ListCharacterInfoType2>() { client.Character.GetListCharacterInfoType2() }));
                //    //client.Send(new BM_SC_SELECT_CHARACTER());
                //}
                //SimpleServer.ConnectedClients.FirstOrDefault(x => x.Account.SessionKey == client.Account.SessionKey).Disconnect(true);
            }
            else
            {
                client.Disconnect();
            }
        }
Exemplo n.º 6
0
 public static void ParseHandler(SimpleClient client, NetworkMessage message)
 {
     try
     {
         Action <object, SimpleClient, NetworkMessage> methodToInvok;
         if (message != null)
         {
             if (MethodHandlers.TryGetValue((HeaderEnum)message.MessageId, out methodToInvok))
             {
                 methodToInvok.Invoke(null, client, message);
             }
             else
             {
                 Console.WriteLine(string.Format("Received non handled Packet : id = {0} -> {1}", message.MessageId, message));
             }
         }
         else
         {
             Console.WriteLine("Receive empty packet");
             client.Disconnect();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 7
0
 public static void ParseStateHandler(SimpleClient client, StateDataMessage message)
 {
     try
     {
         if (message != null)
         {
             if (StateMethodHandlers.TryGetValue((StateTypeEnum)message.MessageId, out var methodToInvok))
             {
                 methodToInvok.Invoke(null, client, message);
             }
             else
             {
                 Console.WriteLine($"Received non handled state : id = {message.MessageId} -> {message}");
             }
         }
         else
         {
             Console.WriteLine("Receive empty state");
             client.Disconnect();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 8
0
 public static void ParseHandler(SimpleClient client, NetworkMessage message)
 {
     try
     {
         if (message != null)
         {
             if (MethodHandlers.TryGetValue((HeaderEnum)message.MessageId, out var methodToInvok))
             {
                 methodToInvok.Invoke(null, client, message);
             }
             else
             {
                 Console.WriteLine($"Received non handled Packet : id = {message.MessageId} -> {message}");
             }
         }
         else
         {
             Console.WriteLine("Receive empty packet");
             client.Disconnect();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 9
0
        public static void HandleCertifyMessage(SimpleClient client, CertifyMessage message)
        {
            GameAccount account;

            if (!CredentialsManager.Instance.CheckAccountValidity(out account, message.username, message.password))
            {
                SendCertifyResultMessage(client, ErrorEnum.ERR_CERT_BAD_PASSWORD, (ErrorEnum)(((int)ErrorEnum.CERT_CHARGE_CERTIFY_FAILED) << 16));
                client.Disconnect();
                return;
            }

            if (!message.realVersion.GetVersionFromCompacted().IsUpToDate())
            {
                SendCertifyResultMessage(client, ErrorEnum.ERR_CERT_VERSION, ErrorEnum.ERR_VERSION_TOO_LOW);
                client.Disconnect();
                return;
            }
            if (SimpleServer.ConnectedClients.Exists(x => x.Account != null && x.Account.Record.Username == message.username))
            {
                SendCertifyResultMessage(client, ErrorEnum.ERR_ACCOUNT_EXIST, ErrorEnum.ERR_ACCOUNT_EXIST);
                client.Disconnect();
                return;
            }
            account.IP_Key = message.ip_key.ToString();
            account.HDSN   = message.hdsn;
            client.Account = account;
            client.Account.Characters.ForEach(x => x.Client = client);

            SendCertifyResultMessage(client);
            CharacterHandler.SendCharactersListMessage(client, DateTime.UtcNow.GetUnixTimeStamp(), 0,
                                                       (byte)client.Account.Characters.Count, 0, 0, client.Account.Characters.Where(x => !x.DeletedDate.HasValue).ToArray(),
                                                       client.Account.Characters.Count(x => x.DeletedDate.HasValue), 0, 0, 0);

            foreach (var character in client.Account.Characters.Where(x => !x.DeletedDate.HasValue))
            {
                CharacterHandler.SendCharacterSlotMessage(client, character, client.Account.Characters.Count(x => x.DeletedDate.HasValue));
            }
        }
Exemplo n.º 10
0
    void MessageDecoder(string msg)
    {
        Hashtable hash = JsonReader.Deserialize <Hashtable>(msg);

        serverMsg = "Message from server: " + msg + "\n\n";

        if (hash.ContainsKey("nbuser"))
        {
            int.TryParse(hash["nbuser"].ToString(), out nbUser);
            serverMsg       += "Users number : " + nbUser;
            sendUserNumberCB = true;
        }
        else if (hash.ContainsKey("users"))
        {
            AllUsers allUsers = JsonReader.Deserialize <AllUsers>(msg);
            kinUsers    = allUsers.users;
            sendUsersCB = true;

            int nbUser = kinUsers == null ? 0 : kinUsers.Length;
            serverMsg += "Deserialized users number: " + nbUser;
        }
        else if (hash.ContainsKey("disconnect"))
        {
            xtionClient.Disconnect();
            serverMsg += "Disconnected from server.";
        }
        else if (hash.ContainsKey("srv_shutdown"))
        {
            xtionClient.Disconnect();
            serverMsg += "Disconnected from server and server killed.";
        }
        else
        {
            serverMsg += "Server command not supported.";
        }
        //Debug.Log( serverMsg );
    }
        public static void HandleJoinMessage(SimpleClient client, JoinMessage message)
        {
            Character character = client.Account.Characters.FirstOrDefault(x => x.Id == message.characterId);

            if (character == null)
            {
                client.Disconnect();
                return;
            }
            client.Character = character;

            SendJoinRightMessage(client, message.characterId, character.Position.Map.SceneId, character.Position.X, character.Position.Y, character.Position.Z, false, 0);//Send all players in the map


            SendSnapshotMessage(client, new Snapshot[] { new SetStateVerSnapshot(1) });
            SendSnapshotMessage(client, new Snapshot[] { new UpdateServerTimeSnapshot(DateTime.Now.GetUnixTimeStamp()) });
            //Thread.Sleep(5000);

            SendSnapshotMessage(client, new Snapshot[] { new AddObjectSnapshot(new CharacterObjectType(ObjectTypeEnum.OT_PLAYER, (uint)client.Character.GetHashCode(), 12, (uint)0,
                                                                                                       client.Character.Position.X, client.Character.Position.Y, client.Character.Position.Z, 0, 0, 100, client.Character.Name, client.Character.Stats.Fields.Count,
                                                                                                       client.Character.Stats.Fields.Keys.Select(x => (ushort)x).ToArray(), client.Character.Stats.Fields.Values.Select(x => x.Total).ToArray(),
                                                                                                       (byte)0, new byte[0], new int[0], new int[0], (uint)client.Character.Id, client.Character.Sex ? (byte)1 : (byte)0, client.Character.Job, (int)client.Account.Authority,
                                                                                                       SimpleServer.ServerId, "", (short)client.Character.Record.Constellation, (short)0, (byte)client.Character.HairMesh,
                                                                                                       client.Character.HairColor, (byte)client.Character.HeadMesh, (uint)0 /*Todo : option*/, 0, "", 0, 0, 0 /*Todo : fame*/,
                                                                                                       0, 0, 0, 0x5322AFDF, 0, 0, new ItemType[0], 0, new byte[0], new int[0], 7, new int[0], 0, 0, new int[0], new int[0],
                                                                                                       new KingdomType((byte)0, (byte)0, 0, $"", (byte)0, 0, 0, 0, 0, 0, 0, $""),
                                                                                                       new MasterType(client.Character.Name, "", "", 0, 0, 0), new MarriageType(0), 0, new int[0], 0, 0, false, true,
                                                                                                       new FlagsDataType(0, 1, 139495485, 0, 0, new int[0], 0, new int[0], 0, new int[0], new int[0],
                                                                                                                         new InventoryType(new short[0], 0, new ItemElementType[0], new short[0]),
                                                                                                                         new QuestInventoryType(new short[0], 0, new ItemElementType[0], new short[0]), 0,
                                                                                                                         new TaskbarType(0, new ShortcutType[0], 0, new ShortcutType[0], 0,
                                                                                                                                         new ShortcutType[0], 0, new byte[0], 0), 0, new SkillType[0],
                                                                                                                         0, false,
                                                                                                                         new FriendListType(FriendStateEnum.FRS_ONLINE, 0, 0, new int[0], 0, new FriendMemberType[0], 0, new FriendMemberType[0], 0, new FriendMemberType[0]),
                                                                                                                         new FactionType(0, 0, 0, 0, 0, "", new ProtegeType[0]), 0,
                                                                                                                         new MemorisedPositionType[0], 0, 0, 0, 0, 0, 0, 0,
                                                                                                                         new CreditCardType(CreditCardTypeEnum.CREDIT_CRAD_NORMAL, 0, 0, 0, 0, 0, 0, (uint)DateTime.Now.GetUnixTimeStamp(), 0, (uint)DateTime.Now.GetUnixTimeStamp(), 0, 0, 0),
                                                                                                                         0, 0, 0, 0, 0, StatsFields.StoneStrenghtBoost, StatsFields.StoneDexterityBoost, StatsFields.StoneStaminaBoost, StatsFields.StoneSPIBoost, StatsFields.StoneIntelligenceBoost,
                                                                                                                         0, new LoverType[0], client.Character.Inventory.ClosetItems.Count, 2, client.Character.Inventory.ClosetItems.Count,
                                                                                                                         client.Character.Inventory.ClosetItems.Values.Select(x => x.GetFateClosetType()).ToArray(),
                                                                                                                         new VesselType(1, 0, 0, 0, 0, new int[0], new WingType[0]), new HotkeyType(0, new HotkeyEnum[0], new HotkeyEnum[0]),
                                                                                                                         new SpiritTatooType(""), new AdventType(0, 0, 0, 0, ""),
                                                                                                                         new PetDomesticateType(0, 0, new PetDomesticateStatsType[0]), new ExpeditionType(1, 0, 0, 0, "", 0), 0, 0, 0))) });

            //foreach(var stats in client.Character.Stats.Fields)
            //{
            //    SendSnapshotMessage(client, new Snapshot[] { new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)stats.Key, (int)stats.Value.Total) });
            //}
        }
Exemplo n.º 12
0
        public static void HandleTS_CS_ACCOUNT(SimpleClient client, TS_CS_ACCOUNT message)
        {
            string login    = message.login.Replace("\0", "");
            string password = message.password.Replace("\0", "");

            AccountRecord record = AccountManager.Instance.GetAccountRecordByLogin(login);

            if (record == null)
            {
                client.Send(new TM_SC_RESULT(0, (ushort)ErrorLoginEnum.MSG_SERVER_NOT_EXIST));
                return;
            }

            if (record.BanTime.HasValue && record.BanTime.Value > DateTime.Now)
            {
                client.Send(new TM_SC_RESULT(0, (ushort)ErrorLoginEnum.MSG_SERVER_DENIED));
                return;
            }

            if (record.PasswordHash != password)
            {
                client.Send(new TM_SC_RESULT(0, (ushort)ErrorLoginEnum.MSG_SERVER_DENIED));
                return;
            }

            SimpleClient clientAlreadyConnected = SimpleServer.ConnectedClients.FirstOrDefault(x => x.Account != null && x.Account.Username == login);

            if (clientAlreadyConnected != null)
            {
                client.Send(new TM_SC_RESULT(0, (ushort)ErrorLoginEnum.MSG_SERVER_ALREADY_EXIST));
                clientAlreadyConnected.Disconnect();
                return;
            }

            string sessionKey = new AsyncRandom().RandomString(32) + '\0';

            client.Account = new Account(record, sessionKey);

            client.Send(new TM_SC_WE_LOGIN((int)ValidKeyEnum.IS_VALID, sessionKey, (int)client.Account.Role, 1));

            AccountManager.Instance.AddTicketAccount(sessionKey, client.Account);
        }
Exemplo n.º 13
0
        public static void ParseHandler(SimpleClient client, NetworkMessage message)
        {
            Action <object, SimpleClient, NetworkMessage> methodToInvok;

            if (message != null)
            {
                if (MethodHandlers.TryGetValue((ushort)message.MessageId, out methodToInvok))
                {
                    methodToInvok.Invoke(null, client, message);
                }
                else
                {
                    client.logger.Warn(string.Format("Received non handled Packet : id = {0} -> {1}", message.MessageId, message));
                }
            }
            else
            {
                client.logger.Error("Received empty packet !");
                client.Disconnect();
            }
        }
Exemplo n.º 14
0
        public async Task Disconnect()
        {
            if (IsRunning)
            {
                IsRunning = false;
                await _connectionTask;
                await _updateTask;

                _client.Disconnect();
            }

            Status = "Disconnected";

            App.Current.Dispatcher.Invoke(delegate
            {
                Messages.Add(new ChatPacket
                {
                    Username  = string.Empty,
                    Message   = "You have disconnected from the server.",
                    UserColor = "black"
                });
            });
        }
Exemplo n.º 15
0
    private void ClientSettingsGUI()
    {
        GUILayout.BeginArea(new Rect(0, buttonHeight + 20, 300, 400));
        client.ServerMode = EditorGUILayout.Toggle("Act as Server", client.ServerMode);

        #region Dropdown connections
        // Generate the connection dropdown options/content
        List <GUIContent> options         = new List <GUIContent>();
        string[]          connectionNames = AmqpConfigurationEditor.GetConnectionNames();

        //if (Event.current.type == EventType.Layout)
        //{
        for (var i = 0; i < connectionNames.Length; i++)
        {
            var cName = connectionNames[i];
            if (string.IsNullOrEmpty(client.Connection) || client.Connection == cName)
            {
                selectedConfigurationIndex = i;
            }
            options.Add(new GUIContent(cName));
        }

        if (options.Count == 0)
        {
            Init();
        }
        //}

        // Connections drop down
        string tooltip = "Select the AMQP connection to use. Connections can be configured in the AMQP/Configuration menu.";
        selectedConfigurationIndex = EditorGUILayout.Popup(new GUIContent("Connection", tooltip), selectedConfigurationIndex, options.ToArray());

        // Set the connection name based on dropdown value
        try
        {
            GUIContent con = options[selectedConfigurationIndex];
            client.Connection = options[selectedConfigurationIndex].text;
        }
        catch (ArgumentException)
        {
            Repaint();
            return;
        }
        #endregion // Dropdown connections
        string connectionString = options[selectedConfigurationIndex].text;

        #region REST-Versuche
        AmqpConnection connection = SimpleClient.GetConnection(connectionString);
        //if (connection != null)
        //{
        //    //string consumers = "http://*****:*****@" + connection.Host + ":" + connection.AmqpPort + "/api/consumers";
        //    //Debug.Log("http://*****:*****@" + connection.Host + ":" + connection.AmqpPort + "/api/consumers");

        //    if (managementAPI == null && client.IsConnected)
        //    {
        //        managementAPI = new RabbitmqManagementAPI(connection);
        //    }

        //    if (overview == null)
        //    {
        //        if (client.IsConnected)
        //        {
        //            overview = managementAPI.Overview();
        //            //overview.Start();
        //        }

        //    }
        //    else
        //    {
        //        Debug.Log("OverviewResult: " + overview.GetResult());
        //        //Debug.Log("overViewRequest != null");
        //        if (client.IsConnected)
        //        {
        //            if (overview.RequestFinished)
        //            {
        //                if (!overview.RequestErrorOccurred)
        //                {
        //                    Debug.Log("not finished: " + overview.ResponseCode.ToString());
        //                }
        //                else
        //                {
        //                    Debug.Log("OverviewResult: " + overview.GetResult());
        //                }
        //            }
        //            else
        //            {
        //                //Debug.Log("not finished: " + overview.ResponseCode.ToString());
        //            }
        //        }
        //    }
        //}


        //if (connection != null)
        //{
        //    //http://10.211.55.2:15672/api/queues
        //    string ourPostData = "";
        //    Dictionary<string, string> headers = new Dictionary<string, string>();
        //    headers.Add("Content-Type", "application/json");

        //    byte[] pData = new byte[0];
        //    string consumers = "http://" + connection.Host + ":" + connection.AmqpPort + "/api/queues";
        //    WWW api = new WWW(consumers, pData, headers);

        //    while (!api.isDone)
        //    {
        //        if (api.error != null)
        //        {
        //            Debug.Log("Error");
        //            break;
        //        }
        //    }

        //    string jsonStr = Encoding.UTF8.GetString(api.bytes);
        //    Debug.Log(consumers + " : " + api.text);
        //}



        //WWW api = new WWW(consumers);

        //while (!api.isDone)
        //{
        //    // wait
        //}
        //Debug.Log("result: " + api.text);

        //UnityWebRequest
        //UnityWebRequest request = UnityWebRequest.Get(consumers);
        //while (!request.isDone || request.isError)
        //{
        //    // wait
        //    if (request.isError)
        //    {
        //        Debug.Log("Error");
        //    }
        //}
        //Debug.Log("result UnityWebRequest: " + request.downloadHandler.text);
        #endregion // REST-Versuche


        if (GUILayout.Button("Awake"))
        {
            client.Awake();
            Repaint();
            return;
        }

        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("EnableUpdate"))
            {
                client.EnableUpdate();
                return;
            }

            if (GUILayout.Button("DisableUpdate"))
            {
                client.DisableUpdate();
                return;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Toggle("IsConnecting?", client.isConnecting);
        EditorGUILayout.Toggle("IsConnected?", client.IsConnected);
        EditorGUILayout.Toggle("hasConnected?", client.hasConnected);
        EditorGUILayout.Toggle("isDisconnecting?", client.isDisconnecting);
        EditorGUILayout.Toggle("hasDisconnected?", client.hasDisconnected);
        EditorGUILayout.Toggle("isReconnecting?", client.isReconnecting);
        EditorGUILayout.Toggle("wasBlocked?", client.wasBlocked);
        EditorGUILayout.Toggle("hasAborted?", client.hasAborted);
        EditorGUILayout.Toggle("canSubscribe?", client.canSubscribe);

        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Connect"))
            {
                client.Connect();
                return;
            }

            if (GUILayout.Button("Disconnect"))
            {
                client.Disconnect();
                return;
            }
        }
        EditorGUILayout.EndHorizontal();

        #region Available Queues
        EditorGUILayout.BeginVertical("box");
        foreach (var queue in client.GetQueues())
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name:", queue.Name);


            if (GUILayout.Button("Subscribe", GUILayout.Width(30)))
            {
                client.SubscribeToQueue(queue.Name);
            }

            if (GUILayout.Button("X", GUILayout.Width(30)))
            {
                client.DeleteQueue(queue.Name);
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
        #endregion Available Queues

        #region Create Queue
        EditorGUILayout.BeginHorizontal("box");
        this.createQueueName = EditorGUILayout.TextField("Queue Name", this.createQueueName);
        if (GUILayout.Button("Create"))
        {
            client.DeclareQueue(this.createQueueName);
        }
        EditorGUILayout.EndHorizontal();
        #endregion // Create Queue

        #region Subscribe Queue
        AmqpQueue[] queues = client.GetQueues();
        string[]    names  = new string[queues.Length];
        for (int i = 0; i < queues.Length; i++)
        {
            names[i] = queues[i].Name;
        }

        selectedQueue = EditorGUILayout.Popup("Queue", selectedQueue, names);
        if (queues.Length != 0)
        {
            if (GUILayout.Button("Subscribe to " + names[this.selectedQueue] + " Queue"))
            {
                client.SubscribeToQueue(names[this.selectedQueue]);
            }
        }
        #endregion // Subscribe Queue

        #region JobQueue
        string[] jobQueueNames = new string[client.GetQueues().Length];
        for (int i = 0; i < client.GetQueues().Length; i++)
        {
            jobQueueNames[i] = client.GetQueues()[i].Name;
        }

        this.jobQueueIndex = EditorGUILayout.Popup("JobQueue", this.jobQueueIndex, jobQueueNames);
        for (int i = 0; i < jobQueueNames.Length; i++)
        {
            if (jobQueueNames[i] == "jobs")
            {
                this.jobQueueIndex = i;
                break;
            }
        }
        jobQueueName = client.GetQueues().Length == 0 ? "not set" : jobQueueNames[this.jobQueueIndex];
        //EditorGUILayout.LabelField("JobQueue", jobQueueName);
        #endregion // JobQueue

        #region ReplyQueue
        string[] replyToQueueNames = new string[client.GetQueues().Length];
        for (int i = 0; i < client.GetQueues().Length; i++)
        {
            replyToQueueNames[i] = client.GetQueues()[i].Name;
        }

        this.replyQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.replyQueueIndex, replyToQueueNames);
        for (int i = 0; i < replyToQueueNames.Length; i++)
        {
            if (replyToQueueNames[i] == "reply")
            {
                this.replyQueueIndex = i;
                break;
            }
        }
        replyQueueName = client.GetQueues().Length == 0 ? "not set" : replyToQueueNames[this.replyQueueIndex];
        //EditorGUILayout.LabelField("ReplyToQueue", replyQueueName);
        #endregion // JobQueue

        #region StatusUpdateQueue
        string[] statusUpdateQueueNames = new string[client.GetQueues().Length];
        for (int i = 0; i < client.GetQueues().Length; i++)
        {
            statusUpdateQueueNames[i] = client.GetQueues()[i].Name;
        }

        this.statusUpdateQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.statusUpdateQueueIndex, statusUpdateQueueNames);
        for (int i = 0; i < statusUpdateQueueNames.Length; i++)
        {
            if (statusUpdateQueueNames[i] == "statusUpdates")
            {
                this.statusUpdateQueueIndex = i;
                break;
            }
        }
        statusUpdateQueueName = client.GetQueues().Length == 0 ? "not set" : statusUpdateQueueNames[this.statusUpdateQueueIndex];
        #endregion // StatusUpdateQueue

        GUILayout.EndArea();
    }