Beispiel #1
0
        public static void RequestAuthForToken(RPCAuthenticateWithTokenMessage message, NPHandler client)
        {
            Debug("enter RequestAuthForToken");

            if (!_instance._connected)
            {
                Debug("exit RequestAuthForToken: not _connected");

                _instance.SendAuthResult(message, client, -1, 0);
                return;
            }

            var token   = Encoding.UTF8.GetString(message.Message.token);
            var request = new SessionData()
            {
                message = message,
                client  = client
            };

            _requests[token] = request;

            var data   = string.Format("checkSession {0} {1}", token, client.Address.Address.ToString());
            var buffer = Encoding.UTF8.GetBytes(data);

            Debug("sending " + data + "to authapi");

            if (!_instance._socket.Poll(0, SelectMode.SelectWrite))
            {
                Log.Error("we can't write to the AuthAPI socket. this seems horrible. what do we do now? sit here and... spin?");

                while (!_instance._socket.Poll(0, SelectMode.SelectWrite))
                {
                    Thread.Sleep(500);

                    Log.Error("let's give it another try");
                }
            }

            try
            {
                _instance._socket.SendTo(buffer, 0, buffer.Length, SocketFlags.None, _serverEP);
            }
            catch (Exception e)
            {
                Log.Error("SendTo failed! " + e.ToString());
            }

            Debug("exit RequestAuthForToken");
        }
Beispiel #2
0
        public static void RequestAuthForToken(RPCAuthenticateWithTokenMessage message, NPHandler client)
        {
            if (!_instance._connected)
            {
                _instance.SendAuthResult(message, client, -1, 0);
                return;
            }

            var token   = Encoding.UTF8.GetString(message.Message.token);
            var request = new SessionData()
            {
                message = message,
                client  = client
            };

            _requests[token] = request;

            var data   = string.Format("checkSession {0} {1}", token, client.Address.Address.ToString());
            var buffer = Encoding.UTF8.GetBytes(data);

            _instance._socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, _instance.Socket_Send, null);
        }