示例#1
0
        public async Task <bool> Authenticate()
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "auth",
                arguments = new JArray()
                {
                    this.Channel.id.ToString(), this.User.id.ToString(), this.channelChat.authkey
                },
            };

            this.authenticateSuccessful = false;
            this.ReplyOccurred         += AuthenticateEventHandler;

            await this.Send(packet);

            for (int i = 0; i < 10 && !this.authenticateSuccessful; i++)
            {
                await Task.Delay(500);
            }

            this.ReplyOccurred -= AuthenticateEventHandler;

            if (this.authenticateSuccessful)
            {
                this.DisconnectOccurred += ChatClient_DisconnectOccurred;
            }

            return(this.authenticateSuccessful);
        }
示例#2
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task ClearMessages()
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "clearMessages",
                arguments = new JArray(),
            };

            await this.Send(packet);
        }
示例#3
0
        private async Task Send(ChatMethodPacket packet)
        {
            packet.id = this.CurrentPacketID;

            string packetJson = JsonConvert.SerializeObject(packet);

            byte[] buffer = this.encoder.GetBytes(packetJson);

            await this.webSocket.SendAsync(new ArraySegment <byte>(buffer), WebSocketMessageType.Text, true, CancellationToken.None);

            this.CurrentPacketID++;
        }
示例#4
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task DeleteMessage(Guid messageID)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "purge",
                arguments = new JArray()
                {
                    messageID
                },
            };

            await this.Send(packet);
        }
示例#5
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task PurgeUser(string username)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "purge",
                arguments = new JArray()
                {
                    username
                },
            };

            await this.Send(packet);
        }
示例#6
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task TimeoutUser(string username, uint durationInSeconds)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "timeout",
                arguments = new JArray()
                {
                    username, durationInSeconds
                },
            };

            await this.Send(packet);
        }
示例#7
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task ChooseVote(uint optionIndex)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "vote",
                arguments = new JArray()
                {
                    optionIndex
                },
            };

            await this.Send(packet);
        }
示例#8
0
        // TODO: Need to figure out how to get correct permissions for command to work
        public async Task StartVote(string question, IEnumerable <string> options, uint timeLimit)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "vote:start",
                arguments = new JArray()
                {
                    question, options, timeLimit
                },
            };

            await this.Send(packet);
        }
示例#9
0
        public async Task Whisper(string username, string message)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "whisper",
                arguments = new JArray()
                {
                    username, message
                },
            };

            await this.Send(packet);
        }
示例#10
0
        public async Task SendMessage(string message)
        {
            ChatMethodPacket packet = new ChatMethodPacket()
            {
                method    = "msg",
                arguments = new JArray()
                {
                    message
                },
            };

            await this.Send(packet);
        }