static Game() { // Initialize loggers logger = new Logger("KINGDOMS", outputToFile: true); logger.SetLevel(Logger.LEVEL.DEBUG); logger.SetConsoleFunction(UnityEngine.Debug.Log); RelayServer.Relay.logger = new Logger("RELAY", outputToFile: true, outputToConsole: false); RelayServer.Relay.logger.SetLevel(Logger.LEVEL.TRACE); Client.logger = new Logger("NETWORK_CLIENT", outputToFile: true, outputToConsole: false); Client.logger.SetLevel(Logger.LEVEL.TRACE); // Start relay server relayServer = new RelayServer.Relay( RelayServer.Config.LOCAL_ADDR, RelayServer.Config.PORT, directMode: true ); new Thread((ThreadStart) delegate { relayServer.WaitUntilDeath().Wait(); }).Start(); Library.Initialize(); chat = new Chat(); // Initialize local player and player list players = new Players(); }
// Default behavior is relaying thing to everyone public virtual void Execute(Relay server, Client client, Session session, Message message) { if (session == null) { throw new Relay.MissingSessionException(message); } foreach (var cl in session.GetClients()) { using (var stream = cl.tcp.NewStream()) { logger.Trace("Broadcasting " + message); stream.Write(message); } } }