Removed IServerPacket interface.
This commit is contained in:
parent
c490dcf128
commit
042b6ddbd6
3 changed files with 7 additions and 12 deletions
|
@ -200,7 +200,7 @@ namespace SharpChat {
|
||||||
HandleDisconnect(user, reason);
|
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))
|
foreach(StoredEventInfo msg in Events.GetChannelEventLog(channelName))
|
||||||
handler(msg.Type switch {
|
handler(msg.Type switch {
|
||||||
"msg:add" => new MessageAddLogPacket(
|
"msg:add" => new MessageAddLogPacket(
|
||||||
|
@ -369,26 +369,26 @@ namespace SharpChat {
|
||||||
RemoveChannel(oldChan);
|
RemoveChannel(oldChan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Send(IServerPacket packet) {
|
public void Send(ServerPacket packet) {
|
||||||
foreach(ConnectionInfo conn in Connections)
|
foreach(ConnectionInfo conn in Connections)
|
||||||
if(conn.IsAuthed)
|
if(conn.IsAuthed)
|
||||||
conn.Send(packet);
|
conn.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendTo(UserInfo user, IServerPacket packet) {
|
public void SendTo(UserInfo user, ServerPacket packet) {
|
||||||
foreach(ConnectionInfo conn in Connections)
|
foreach(ConnectionInfo conn in Connections)
|
||||||
if(conn.IsAuthed && conn.User!.UserId == user.UserId)
|
if(conn.IsAuthed && conn.User!.UserId == user.UserId)
|
||||||
conn.Send(packet);
|
conn.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendTo(ChannelInfo channel, IServerPacket packet) {
|
public void SendTo(ChannelInfo channel, ServerPacket packet) {
|
||||||
long[] userIds = ChannelsUsers.GetChannelUserIds(channel);
|
long[] userIds = ChannelsUsers.GetChannelUserIds(channel);
|
||||||
foreach(ConnectionInfo conn in Connections)
|
foreach(ConnectionInfo conn in Connections)
|
||||||
if(conn.IsAuthed && userIds.Contains(conn.User!.UserId))
|
if(conn.IsAuthed && userIds.Contains(conn.User!.UserId))
|
||||||
conn.Send(packet);
|
conn.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendToUserChannels(UserInfo user, IServerPacket packet) {
|
public void SendToUserChannels(UserInfo user, ServerPacket packet) {
|
||||||
ChannelInfo[] chans = GetUserChannels(user);
|
ChannelInfo[] chans = GetUserChannels(user);
|
||||||
foreach(ChannelInfo chan in chans)
|
foreach(ChannelInfo chan in chans)
|
||||||
SendTo(chan, packet);
|
SendTo(chan, packet);
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace SharpChat {
|
||||||
RemotePort = (ushort)sock.ConnectionInfo.ClientPort;
|
RemotePort = (ushort)sock.ConnectionInfo.ClientPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Send(IServerPacket packet) {
|
public void Send(ServerPacket packet) {
|
||||||
if(!Socket.IsAvailable)
|
if(!Socket.IsAvailable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
namespace SharpChat {
|
namespace SharpChat {
|
||||||
public interface IServerPacket {
|
public abstract class ServerPacket {
|
||||||
long SequenceId { get; }
|
|
||||||
string Pack();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class ServerPacket : IServerPacket {
|
|
||||||
public long SequenceId { get; }
|
public long SequenceId { get; }
|
||||||
|
|
||||||
public ServerPacket(long sequenceId = 0) {
|
public ServerPacket(long sequenceId = 0) {
|
||||||
|
|
Loading…
Reference in a new issue