public static void Send(Helpers.TcpGameWorld changes) { Logging.Info("[Server] Sending GameWorldChanges to all clients"); foreach (Helpers.User user in Users) { server.Send(user.ID, changes.Serialize()); } }
static void OnGameWorldReceived(Helpers.TcpGameWorld world) { GameWorld.World changes = (GameWorld.World)world.Data.GetValue("changes"); bool addition = (bool)world.Data.GetValue("addition"); Logging.Info($"[Client] Updating GameWorld => " + addition); GameWorld.Client.Instance.UpdateLocalWorld(changes, addition); }
static void Receive(byte[] data) { Logging.Info("[Client] Data from Server: " + data.Length + " bytes"); //Handle TcpResponse Helpers.TcpResponse tcpresponse = Helpers.TcpResponse.Deserialize(data); if (tcpresponse != null && tcpresponse.Header == "response") { OnServerResponse(tcpresponse); } //Handle TcpServerChat Helpers.TcpServerChat tcpServerChat = Helpers.TcpServerChat.Deserialize(data); if (tcpServerChat != null && tcpServerChat.Header == "serverchat") { OnServerChatRecieved(tcpServerChat); } //Handle TcpChat Helpers.TcpChat tcpchat = Helpers.TcpChat.Deserialize(data); if (tcpchat != null && tcpchat.Header == "chat") { OnChatReceived(tcpchat); } //Handle GameWorld Helpers.TcpGameWorld tcpworld = Helpers.TcpGameWorld.Deserialize(data); if (tcpworld != null && tcpworld.Header == "gameworld") { OnGameWorldReceived(tcpworld); } //Handle Gamespeed Helpers.TcpGamespeed tcpspeed = Helpers.TcpGamespeed.Deserialize(data); if (tcpspeed != null && tcpspeed.Header == "gamespeed") { OnGamespeedChange(tcpspeed); } }
public static void Send(int clientid, Helpers.TcpGameWorld changes) { Logging.Info("[Server] Sending GameWorldChanges to client " + clientid + " => " + (bool)changes.Data.GetValue("addition")); server.Send(clientid, changes.Serialize()); }
public static void Send(Helpers.TcpGameWorld changes) { Logging.Info("[Client] Sending gameworld update"); client.Send(changes.Serialize()); }