Started converting websocket and rpc classes

This commit is contained in:
RogueException
2016-09-28 04:12:17 -03:00
parent 0c4641ac68
commit dd86f03306
107 changed files with 1836 additions and 1882 deletions

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Channel;
namespace Discord.WebSocket
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class SocketChannel : SocketEntity<ulong>, IChannel
{
internal SocketChannel(DiscordSocketClient discord, ulong id)
: base(discord, id)
{
}
internal static SocketChannel Create(DiscordSocketClient discord, Model model)
{
switch (model.Type)
{
case ChannelType.Text:
return SocketTextChannel.Create(discord, model);
case ChannelType.Voice:
return SocketVoiceChannel.Create(discord, model);
case ChannelType.DM:
return SocketDMChannel.Create(discord, model);
case ChannelType.Group:
return SocketGroupChannel.Create(discord, model);
default:
throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
}
}
//IChannel
IReadOnlyCollection<IUser> IChannel.CachedUsers => ImmutableArray.Create<IUser>();
IUser IChannel.GetCachedUser(ulong id)
=> null;
Task<IUser> IChannel.GetUserAsync(ulong id)
=> Task.FromResult<IUser>(null);
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync()
=> ImmutableArray.Create<IReadOnlyCollection<IUser>>().ToAsyncEnumerable();
}
}