private void sendToAll(string s) { Msg msg = new Msg(); msg.text = WaitingRoom.AddDate(s); foreach (Player p in players) { p.con.SendObject <Msg>("Msg", msg); } }
public ServerNetwork(WaitingRoom nroom, int port) { room = nroom; NetworkComms.AppendGlobalIncomingPacketHandler <Hello>("Hello", processHello); NetworkComms.AppendGlobalIncomingPacketHandler <Msg>("Msg", processMsg); NetworkComms.AppendGlobalIncomingPacketHandler <GameCommand>("GameCommand", processGC); NetworkComms.AppendGlobalConnectionCloseHandler(ClientDisconnected); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Parse("127.0.0.1"), port)); Console.WriteLine("Listening for messages on:"); foreach (System.Net.IPEndPoint localEndPoint in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) { Console.WriteLine("{0}:{1}", localEndPoint.Address, localEndPoint.Port); } }
public static void Main(string[] args) { WaitingRoom room = new WaitingRoom(); ServerNetwork net; if (args.Length >= 1) { if (Int32.TryParse(args[0], out port)) { Console.WriteLine("Using port { " + args[0] + " }."); } } else { Console.WriteLine("No arguments given, taking default port { 27960 }."); } net = new ServerNetwork(room, port); Console.WriteLine("Launching waiting loop"); room.waitForGame(); }