Web host - Chapter 22 Networking: Streams-Based Sockets and Datagrams 1139

Chapter 22 Networking: Streams-Based Sockets and Datagrams 1139 ated NetworkStream object from TcpClient (line 74). Lines 80 81 start a thread to read messages sent from the server to the client. The server passes messages (for example, whether each move is valid) to method ProcessMessage(lines 163 207). If the message indicates that a move is valid (line 168), the client sets its mark to the current square (the square that the user clicked) and repaints the board. If the message indicates that a move is invalid (line 178), the client notifies the user to click a different square. If the message indicates that the opponent made a move (line 185), line 188 reads from the server an intspecifying where on the board the client should place the opponent s mark. 1 // Fig. 22.7: Square.cs 2 // A Square on the TicTacToe board. 3 4 using System.Windows.Forms; 5 6 // the representation of a square in a tic-tac-toe grid 7 public class Square 8 { 9 private Panel panel; 10 private char mark; 11 private int location; 12 13 // constructor 14 public Square( Panel newPanel, char newMark, int newLocation ) 15 { 16 panel = newPanel; 17 mark = newMark; 18 location = newLocation; 19 } 20 21 // property SquarePanel; the panel which the square represents 22 public Panel SquarePanel 23 { 24 get 25 { 26 return panel; 27 } 28 } // end property SquarePanel 29 30 // property Mark; the mark of the square 31 public char Mark 32 { 33 get 34 { 35 return mark; 36 } 37 38 set 39 { 40 mark = value; 41 } 42 } // end property Mark Fig. 22.7 Fig. 22.7Fig. 22FiFi.7g. 22.7g. 22.7Class Square. (Part 1 of 2.)
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services

Leave a Reply