Removed IServerPacket interface.

This commit is contained in:
flash 2024-05-20 01:35:39 +00:00
parent c490dcf128
commit 042b6ddbd6
3 changed files with 7 additions and 12 deletions

View file

@ -200,7 +200,7 @@ namespace SharpChat {
HandleDisconnect(user, reason);
}
public void HandleChannelEventLog(string channelName, Action<IServerPacket> handler) {
public void HandleChannelEventLog(string channelName, Action<ServerPacket> handler) {
foreach(StoredEventInfo msg in Events.GetChannelEventLog(channelName))
handler(msg.Type switch {
"msg:add" => new MessageAddLogPacket(
@ -369,26 +369,26 @@ namespace SharpChat {
RemoveChannel(oldChan);
}
public void Send(IServerPacket packet) {
public void Send(ServerPacket packet) {
foreach(ConnectionInfo conn in Connections)
if(conn.IsAuthed)
conn.Send(packet);
}
public void SendTo(UserInfo user, IServerPacket packet) {
public void SendTo(UserInfo user, ServerPacket packet) {
foreach(ConnectionInfo conn in Connections)
if(conn.IsAuthed && conn.User!.UserId == user.UserId)
conn.Send(packet);
}
public void SendTo(ChannelInfo channel, IServerPacket packet) {
public void SendTo(ChannelInfo channel, ServerPacket packet) {
long[] userIds = ChannelsUsers.GetChannelUserIds(channel);
foreach(ConnectionInfo conn in Connections)
if(conn.IsAuthed && userIds.Contains(conn.User!.UserId))
conn.Send(packet);
}
public void SendToUserChannels(UserInfo user, IServerPacket packet) {
public void SendToUserChannels(UserInfo user, ServerPacket packet) {
ChannelInfo[] chans = GetUserChannels(user);
foreach(ChannelInfo chan in chans)
SendTo(chan, packet);

View file

@ -44,7 +44,7 @@ namespace SharpChat {
RemotePort = (ushort)sock.ConnectionInfo.ClientPort;
}
public void Send(IServerPacket packet) {
public void Send(ServerPacket packet) {
if(!Socket.IsAvailable)
return;

View file

@ -1,10 +1,5 @@
namespace SharpChat {
public interface IServerPacket {
long SequenceId { get; }
string Pack();
}
public abstract class ServerPacket : IServerPacket {
public abstract class ServerPacket {
public long SequenceId { get; }
public ServerPacket(long sequenceId = 0) {