def main(): import video_server # run main event loop here from twisted.internet import app from twisted.cred.authorizer import DefaultAuthorizer from twisted.manhole.telnet import ShellFactory appl = app.Application("videoserver") auth = DefaultAuthorizer(appl) svr = video_server.SimpleService("video_server",appl,auth) svr.perspectiveClass = video_server.SimplePerspective p1 = svr.createPerspective("video") i1 = auth.createIdentity("video") i1.setPassword("****") i1.addKeyByString("video_server", "video") auth.addIdentity(i1) fls = video_server.VideoFactory(svr,"193.197.169.185","8789") # sf = ShellFactory() # sf.username = '******' # sf.password = '******' # sf.namespace['server'] = svr # sf.namespace['quit'] = video_server.quit # # appl.listenTCP(8790, sf) appl.listenTCP(8789,fls) appl.listenTCP(8788, pb.BrokerFactory(pb.AuthRoot(auth))) appl.run()
def main(): """...""" from twisted.spread import pb from twisted.application import service from twisted.cred.authorizer import DefaultAuthorizer from twisted.internet import reactor, app evManager = EventManager() sharedObjectRegistry = {} log = TextLogView(evManager) timer = TimerController(evManager, reactor) #clientContr = NetworkClientController( evManager, sharedObjectRegistry ) clientView = NetworkClientView(evManager, sharedObjectRegistry) game = Game(evManager) #from twisted.spread.jelly import globalSecurity #globalSecurity.allowModules( network ) application = app.Application("myServer") auth = DefaultAuthorizer(application) #create a service, tell it to generate NetworkClientControllers serv = pb.Service("myService", application, auth) serv.perspectiveClass = NetworkClientController #create a Perspective per1 = serv.createPerspective("perspective1") per1.PostInit(evManager, sharedObjectRegistry) #create an Identity iden1 = auth.createIdentity("user1") iden1.setPassword("asdf") #allow it access to the perspective named perspective1 iden1.addKeyByString("myService", "perspective1") auth.addIdentity(iden1) #application.listenTCP(8000, pb.BrokerFactory(clientContr) ) application.listenTCP(8000, pb.PBServerFactory(pb.AuthRoot(auth))) application.run(save=0)