def test___init__(self): server=EchoGameServer(host,port,data_size,msghand,maxPlayers) self.assertRaises(OSError, EchoGameServer, host,port,data_size,msghand,maxPlayers) client1=EchoGameClient(host,port,data_size,msghand) self.assertTrue(client1.status()) client2=EchoGameClient(host,port+1,data_size,msghand) self.assertFalse(client2.status())
from Game_TTT.TTT_MessageHandler import TTT_MessageHandler from Echo.EchoClient import EchoGameClient from TickTackToo.TickTackTooStage import TickTackTooStage, getCoordinate import sys stage = TickTackTooStage() adress = 'localhost' port = 50015 data_size = 1024 msghand = TTT_MessageHandler() client = EchoGameClient(adress, port, data_size, msghand) if client.status(): client.sendName() else: sys.exit() if client.status(): client.promt() while client.status(): ans = client.handle_connection() if ans: who, typ, message = ans else: continue
def test_ClientStatus(self): client=EchoGameClient(host,port,data_size,msghand) client.socketStatus = False self.assertFalse(client.status()) client.socketStatus = True self.assertTrue(client.status())