mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-17 17:05:10 +00:00
only send game packet on join to connected clients
This commit is contained in:
parent
e2f2f76669
commit
f8c7d696a1
2 changed files with 2 additions and 1 deletions
|
@ -26,7 +26,7 @@ server.ClientJoined += (c, _) => {
|
||||||
c.Metadata["scenario"] = (byte?) 0;
|
c.Metadata["scenario"] = (byte?) 0;
|
||||||
c.Metadata["2d"] = false;
|
c.Metadata["2d"] = false;
|
||||||
c.Metadata["speedrun"] = 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 {
|
try {
|
||||||
c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client).Wait();
|
c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client).Wait();
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Server;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
public readonly List<Client> Clients = new List<Client>();
|
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");
|
public readonly Logger Logger = new Logger("Server");
|
||||||
private readonly MemoryPool<byte> memoryPool = MemoryPool<byte>.Shared;
|
private readonly MemoryPool<byte> memoryPool = MemoryPool<byte>.Shared;
|
||||||
public Func<Client, IPacket, bool>? PacketHandler = null!;
|
public Func<Client, IPacket, bool>? PacketHandler = null!;
|
||||||
|
|
Loading…
Reference in a new issue