public static void Message(byte[] s, WebSocketWrapper wrapper) { using (BinaryReader b = new BinaryReader(new MemoryStream(s))) { byte id = b.ReadByte(); RecordPacket(id); if (id == 16) //Player Packet { if (_agarWorld != null) { _agarWorld.Read(b); } } else if (id == 32) //Player entry packet { _agarWorld.PlayerId = b.ReadUInt32(); _showPopup = false; } else if (id == 49) //Leaderboard List { _leaderboard = ReadLeaderboard(b); } else if (id == 64) //World size packet { _agarWorld = new World(b.ReadDouble(), b.ReadDouble(), b.ReadDouble(), b.ReadDouble()); _agarWorld.PlayerDied += _agarWorld_PlayerDied; } else { throw new Exception(); } } }
public static void DisposeWorld() { _connected = false; if (_ws != null) _ws.Close(); _ws = null; if (_agarWorld != null) _agarWorld.PlayerDied -= _agarWorld_PlayerDied; _agarWorld = null; _showPopup = true; _ipAddress = ""; _leaderboard = new List<LeaderboardPlayer>(); }