using Content.Server.Interfaces; using System; using System.Collections.Generic; using System.Text; namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork { /// /// A collection of utilities to help with using device networks /// public static class NetworkUtils { public const int PRIVATE = 0; public const int WIRED = 1; public const int WIRELESS = 2; public const string COMMAND = "command"; public const string MESSAGE = "message"; public const string PING = "ping"; /// /// Handles responding to pings. /// public static void PingResponse(T connection, string sender, IReadOnlyDictionary payload, string message = "") where T : IDeviceNetworkConnection { if (payload.TryGetValue(COMMAND, out var command) && command == PING) { var response = new Dictionary { {COMMAND, "ping_response"}, {MESSAGE, message} }; connection.Send(connection.Frequency, sender, response); } } } }