Пример #1
0
 public async Task DeleteMessage(ulong channelId, Opcode.Message message)
 {
     await this.DeleteMessage(channelId, message.Id.Id);
 }
Пример #2
0
        private void OpcodeDispatch(Payload payload)
        {
            switch (payload.Opcode)
            {
            case 0:     // Dispatch
                this._last_sequence_number = (int)payload.SequenceNumber;
                //this.messageLog.Write(payload.Data.ToString());
                //this.messageLog.FlushAsync().Wait();
                switch (payload.EventName)
                {
                case "CHANNEL_CREATE":
                    if (this.OnChannelCreate != null)
                    {
                        Opcode.Channel channel = JsonConvert.DeserializeObject <Opcode.Channel>(payload.Data.ToString());
                        this.OnChannelCreate(channel);
                    }
                    break;

                case "CHANNEL_UPDATE":
                    if (this.OnChannelUpdate != null)
                    {
                        Opcode.Channel channel = JsonConvert.DeserializeObject <Opcode.Channel>(payload.Data.ToString());
                        OnChannelUpdate(channel);
                    }
                    break;

                case "CHANNEL_DELETE":
                    if (this.OnChannelDelete != null)
                    {
                        Opcode.Channel channel = JsonConvert.DeserializeObject <Opcode.Channel>(payload.Data.ToString());
                        this.OnChannelDelete(channel);
                    }
                    break;

                case "CHANNEL_PINS_UPDATE":
                    break;

                case "GUILD_CREATE":
                    break;

                case "GUILD_UPDATE":
                    break;

                case "GUILD_DELETE":
                    break;

                case "GUILD_BAN_ADD":
                    break;

                case "GUILD_BAN_REMOVE":
                    break;

                case "GUILD_EMOJIS_UPDATE":
                    break;

                case "GUILD_INTEGRATIONS_UPDATE":
                    break;

                case "GUILD_MEMBER_ADD":
                    break;

                case "GUILD_MEMBER_REMOVE":
                    break;

                case "GUILD_MEMBER_UPDATE":
                    break;

                case "GUILD_MEMBERS_CHUNK":
                    break;

                case "GUILD_ROLE_CREATE":
                    break;

                case "GUILD_ROLE_UPDATE":
                    break;

                case "GUILD_ROLE_DELETE":
                    break;

                case "READY":
                    Opcode.Ready ready = JsonConvert.DeserializeObject <Opcode.Ready>(payload.Data.ToString());
                    this._me         = ready.User;
                    this._session_id = ready.SessionId;
                    if (this.OnReady != null)
                    {
                        OnReady(ready);
                    }
                    break;

                case "PRESENCE_UPDATE":
                    if (this.OnPresenceUpdate != null)
                    {
                        Opcode.PresenceUpdate presence = JsonConvert.DeserializeObject <Opcode.PresenceUpdate>(payload.Data.ToString());
                        OnPresenceUpdate(presence);
                    }
                    break;

                case "TYPING_START":
                    //Opcode.TypingStart typing = JsonConvert.DeserializeObject<Opcode.TypingStart>(payload.Data.ToString());
                    //OnTypingStart(typing);
                    break;

                case "MESSAGE_CREATE":
                    if (this.OnMessageCreate != null)
                    {
                        Opcode.Message message = JsonConvert.DeserializeObject <Opcode.Message>(payload.Data.ToString());
                        OnMessageCreate(message);
                    }
                    break;

                default:
                    Console.WriteLine(payload.EventName);
                    break;
                }
                break;

            case 7:     // Reconnect
                break;

            case 9:     // Invalid session
                break;

            case 10:     //Hello
                Opcode.Hello hello = JsonConvert.DeserializeObject <Opcode.Hello>(payload.Data.ToString());
                this._timer           = new System.Timers.Timer(hello.HeartbeatInterval);
                this._timer.AutoReset = true;
                this._timer.Elapsed  += (source, e) => this.HeartBeat();
                this._timer.Enabled   = true;
                break;

            case 11:     // Heartbeat acknowledge
                break;

            default:
                //Console.WriteLine(JsonConvert.SerializeObject(payload));
                break;
            }
        }
Пример #3
0
 public async Task <Opcode.Message> CreateMessage(ulong channelId, Opcode.Message message)
 {
     throw new NotImplementedException();
 }