//Main constructor private Server(string address, int port, ServerForm serverForm) { this.IPAddress = address; this.Port = System.Net.IPAddress.HostToNetworkOrder(port); ReceiveBuffer = new byte[1024]; clientSocketList = new ConcurrentDictionary<Socket, Players>(); _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); ServerForm = serverForm; }
public Game(ServerForm serverForm, Server server) { ServerForm = serverForm; Server = server; CurrentRoleDeck = new List<PlayingCards>(); CurrentKing = -1; CurrentLadyLake = -1; CurrentTeamSelectionRound = 1; CurrentRound = 1; MaxRounds = 5; MaxTeamMembersCurrentRound = 5; MatchOver = true; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ServerForm serverForm = new ServerForm(); Server server = Server.GetServer(serverForm); Game game = new Game(serverForm, server); ThreadPool.QueueUserWorkItem(delegate { game.Run(); }); serverForm.ShowDialog(); }
public static Server GetServer(ServerForm form) { return _server ?? (_server = new Server("192.168.1.1", 8814, form)); }