Example #1
0
 private void OnClientDisconnected(FakeClient obj, bool planned)
 {
     if (!obj.ConnectingToWorld)
     {
         m_clients.Remove(obj);
     }
 }
Example #2
0
        public FakeClient AddAndConnectClient()
        {
            var client = new FakeClient(m_idProvider.Pop());

            m_clients.Add(client);

            if (!m_fakeAccountsId.Contains(client.Id))
            {
                var account = new AccountData()
                {
                    Login           = AccountName + client.Id,
                    PasswordHash    = AccountPassword.GetMD5(),
                    Nickname        = AccountName + client.Id,
                    UserGroupId     = FakeUserGroup,
                    AvailableBreeds = BreedManager.AvailableBreeds,
                    SecretQuestion  = "fakeclient",
                    SecretAnswer    = "fakeclient",
                    Lang            = "fr",
                };

                var msg = new CreateAccountMessage();
                msg.Account = account;

                IPCAccessor.Instance.SendRequest(msg, x =>
                {
                    m_fakeAccountsId.Add(client.Id);
                    client.Connect(IP, Port);
                    client.Disconnected += OnClientDisconnected;
                }, x =>
                {
                    client.Disconnect();
                    m_clients.Remove(client);
                });
            }
            else
            {
                client.Connect(IP, Port);
                client.Disconnected += OnClientDisconnected;
            }


            return(client);
        }