Example #1
0
        /// <summary> 
        /// Constructor for TwoServerWindow, creates udp receptor thread and creates listening sockets, spawns
        /// a game options window, and prepares the server to accept clients
        /// </summary> 
        public TwoServerWindow()
        {
            InitializeComponent();
            PlayerList = new PlayerList(this);
            IPHostEntry localHostEntry;
            try
            {
                //Create a UDP socket.
                _udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                localHostEntry = Dns.GetHostEntry(Dns.GetHostName());
            }
            catch (Exception)
            {
                //If the socket can't be created the server can't work
                AddText("Local Host not found");
                return;
            }
            IPAddress localIp = null;
            foreach (IPAddress ip in localHostEntry.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                    localIp = ip;
            }

            _localEndPoint = new IPEndPoint(localIp, 48484);
            _udpSocket.Bind(_localEndPoint);
            Show();
            GameOption = new GameOptions();
            GameOption.ShowDialog();

            _udpThread = new Thread(new ThreadStart(RecieveUdp));
            _udpThread.Start();
            _broadcastThread = new Thread(new ThreadStart(BroadcastServerThread));
            _broadcastThread.Start();
            UdpMessageEvent += new UdpMessageHandler(UdpMessageListener);
            DownDeck = new Stack<Card>();
        }
Example #2
0
 /// <summary> 
 /// Event handler for clicking the game options button
 /// </summary>
 private void OptionsButton_Click(object sender, EventArgs e)
 {
     GameOptions g = new GameOptions();
     g.Show();
 }
Example #3
0
 public void GameOptionsConstructorTest()
 {
     GameOptions target = new GameOptions();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }