Ejemplo n.º 1
0
        public async Task IntializeReceiver(string streamId, string email = null, string password = null)
        {
            if (Role != null)
            {
                throw new Exception("Role changes are not permitted. Maybe create a new client?");
            }

            Role     = ClientRole.Receiver;
            StreamId = streamId;

            try
            {
                var payload = new PayloadAccountLogin()
                {
                    Email = email, Password = password
                };
                AuthToken = (await this.UserLoginAsync(payload)).ApiToken;
                User      = (await this.UserGetProfileAsync()).User;
            }
            catch
            {
                throw new Exception("Login error. Credentials incorrect.");
            }

            try
            {
                Stream = (await this.StreamGetAsync(streamId)).Stream;
                var x = Stream;
            }
            catch { throw new Exception("Could not get stream."); }
        }
Ejemplo n.º 2
0
        public async Task <string> IntializeSender(string email, string password)
        {
            if (Role != null)
            {
                throw new Exception("Role changes are not permitted. Maybe create a new client?");
            }

            Role = ClientRole.Sender;

            try
            {
                var payload = new PayloadAccountLogin()
                {
                    Email = email, Password = password
                };
                AuthToken = (await this.UserLoginAsync(payload)).ApiToken;
                User      = (await this.UserGetProfileAsync()).User;
            }
            catch
            {
                throw new Exception("Login error. Credentials incorrect.");
            }

            try
            {
                Stream   = (await this.StreamCreateAsync()).Stream;
                StreamId = Stream.StreamId;
                LogEvent("Created a new stream.");
                await SetupClient();

                SetupWebsocket();

                return(Stream.StreamId);
            }
            catch
            {
                throw new Exception("Failed to create a new stream.");
            }
        }