Prev | Current Page 831 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

net.RemotingServer;
class TicTacToeServer
{
private static function main()
{
var s = new neko.net.ThreadRemotingServer();
s.initClientApi = initClientApi;
s.clientDisconnected = clientDisconnected;
(continued)
Chapter 15: Putting It All Together with haXe Remoting
451
trace(???TicTacToe server...???);
s.run(???localhost???, 2001);
}
private static var attendants = new List < PlayerServer > ();
private static function initClientApi(scnx:SocketConnection,
server:RemotingServer)
{
var p = new PlayerServer(scnx);
server.setPrivatePrefix(???_???);
server.addObject(???PlayerServer???, p);
(cast scnx).__player = p;
addAttendant(p);
}
public static function clear(p : PlayerServer)
{
if(p.board == null)
return;
p.board = p.other.board = null;
p.other = p.other.other = null;
}
private static function clientDisconnected(scnx)
{
var p : PlayerServer = (cast scnx).__player;
if(p.other != null)
p.other.client.adversaryQuit();
clear(p);
manageGames();
}
private static function manageGames()
{
while(attendants.


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