Esempio n. 1
0
        private void OnAuthorizeReceived(IUdpNetwork network, IOwner owner, string name, ICallbacks callbacks)
        {
            if (string.IsNullOrEmpty(name))
            {
                Console.WriteLine("Authorized failed, empty name, address {0}", owner.Id);
                callbacks.Fail(_incorrectUsername);
                _network.Authorize(owner, false);
                return;
            }

            foreach (var item in _clients.Values)
            {
                if (item == name)
                {
                    Console.WriteLine("Authorized failed, dublicate name, address {0}", owner.Id);
                    callbacks.Fail(_dublicateUsername);
                    _network.Authorize(owner, false);
                    return;
                }
            }
            Console.WriteLine("Authorized true, address: {0}", owner.Id);

            callbacks.Ack(_ok);
            _network.Authorize(owner, true);
            _clients.Add(owner, name);
        }
Esempio n. 2
0
 public override void Ack(string value)
 {
     _network.Authorize(_owner, true);
     _chatClient.SuccessAuthorize();
 }
Esempio n. 3
0
 public void Authorize(string name)
 {
     _name = name;
     _network.Authorize(_owner, name, new AuthorizedCallbacks(_network, _owner, this));
     CallChangeStage(ClientStage.Authorizing);
 }