Beispiel #1
0
        private void Dispose(bool disposing)
        {
            if (_disposed) return;
            if (!disposing) return;

            CurrentSession = null;

            _action = null;
            _disposed = true;
        }
Beispiel #2
0
        public async Task<LolSession> Login(IRtmpConnection connection, AuthenticationCredentials credentials)
        {
            Credentials = credentials;

            var invoke = new Invocation<LolSession>("loginService", "login", credentials);
            CurrentSession = await invoke.Execute(connection);

            await AuthorizeSession(connection, CurrentSession);

            if (_action != null)
                _action();

            return CurrentSession;
        }
Beispiel #3
0
        private static async Task AuthorizeSession(IRtmpConnection connection, LolSession session)
        {
            connection.AddHeader(MessageBase.FlexClientIdHeader, false, session.token);

            // note: username is case sensitive here for some reason...
            var token = string.Format("{0}:{1}", session.accountSummary.username, session.token);
            var tokenEncoded = Encoding.ASCII.GetBytes(token);
            var body = Convert.ToBase64String(tokenEncoded);
            var msg = new CommandMessage
            {
                operation = CommandMessage.LoginOperation,
                clientId = connection.ClientId,
                correlationId = null,
                messageId = Guid.NewGuid().ToString(),
                body = body,
                destination = string.Empty
            };

            await new Invocation<string>("auth", msg).Execute(connection);
        }
Beispiel #4
0
        void OnLogin(Session session)
        {
            // Client header should be set to the token we received from REST authentication
            RPCNetConnection.AddHeader(MessageBase.FlexClientIdHeader, false, session.token);

            // Create the command message which will do flex authentication
            CommandMessage message = new CommandMessage();
            message.operation = CommandMessage.LoginOperation;
            message.body = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(ConnectionData.User + ":" + session.token));
            message.clientId = RPCNetConnection.ClientId;
            message.correlationId = null;
            message.destination = "";
            message.messageId = Guid.NewGuid().ToString();

            // Perform flex authentication.
            RPCNetConnection.Call("auth", new Responder<string>(OnFlexLogin, OnFlexLoginFault), message);
        }