Prev | Current Page 829 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This reference is used to send messages to the
adversary when the turn() is concluded or when the first player disconnects from the server.
class GameClientApi extends haxe.remoting.AsyncProxy < IGameClient > {}
class PlayerServer implements IPlayerServer
{
public var client : GameClientApi;
public var board : GameBoard;
public var isPlayerOne : Bool;
public var isActive : Bool;
public var other : PlayerServer;
public function new(scnx : haxe.remoting.SocketConnection)
{
client = new GameClientApi(scnx.client);
}
(continued)
Part II: Server Side, JavaScript, and Flash: Oh My!
450
public function _turn() : Void
{
isActive = true;
other.isActive = false;
client.yourTurn(board.grid);
other.client.otherTurn(board.grid);
}
public function place(row : Int, col : Int) : Void
{
if(board == null || !isActive)
return;
if(board.place(isPlayerOne, row, col))
{
if(board.checkWinner())
{
client.winner(board.grid);
other.client.looser(board.grid);
TicTacToeServer.clear(this);
} else if(board.checkTie()) {
client.


Pages:
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841