Ejemplo n.º 1
0
#!/usr/bin/env python2
# Distributed under the terms of the GNU GPLv3
# Copyright 2010 Berin Smaldon
from game.world import World
from twisted.internet import reactor
import sys

if __name__ == '__main__':
    if len(sys.argv) > 1:
        bq = World(sys.argv[1])
    else:
        bq = World('data/bq.meta')

    s = reactor.listenTCP(bq.getPort( ), bq.getFactory( ))
    bq.animate(reactor, s)

    reactor.run( )
Ejemplo n.º 2
0
        raise NeverCallMeError, "Received excess data"
    
    def connectionLost(self):
        assert self.state == 'never', "Premature closure"
        print "Successful transaction with the game world!"
        reactor.stop( )

class TestClientFactory(ClientFactory):
    def __init__(self, world):
        self.world = world

    def startedConnecting(self, connector):
        print "Connecting"

    def buildProtocol(self, addr):
        return StatefulTestRig(self.world)
    
    def clientConnectionLost(self, connector, reason):
        print "Connection lost:", reason

    def clientConnectionFailed(self, connector, reason):
        raise ConnectionError, "Could not connect: "+reason

if __name__ == '__main__':
    world = World(None)
    clientFactory = TestClientFactory(world)
    
    reactor.listenTCP(8001, world.getFactory( ))
    reactor.connectTCP('localhost', 8001, clientFactory)
    reactor.run( )