0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-22 03:05:16 +00:00

only send game packet on join to connected clients

This commit is contained in:
CraftyBoss 2022-07-08 23:13:35 +00:00
parent 72061215ce
commit 11015bd445
2 changed files with 2 additions and 1 deletions

View file

@ -26,7 +26,7 @@ server.ClientJoined += (c, _) => {
c.Metadata["scenario"] = (byte?) 0;
c.Metadata["2d"] = false;
c.Metadata["speedrun"] = false;
foreach (Client client in server.Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket")).ToArray()) {
foreach (Client client in server.ClientsConnected) {
try {
c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client).Wait();
} catch {

View file

@ -10,6 +10,7 @@ namespace Server;
public class Server {
public readonly List<Client> Clients = new List<Client>();
public IEnumerable<Client> ClientsConnected => Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket") && client.Connected);
public readonly Logger Logger = new Logger("Server");
private readonly MemoryPool<byte> memoryPool = MemoryPool<byte>.Shared;
public Func<Client, IPacket, bool>? PacketHandler = null!;