def doLogin(self, widget): name = self.form.widget_user.text pwd = self.form.widget_pass.text Events.do('showConsole') print "Opening stream socket..." tcp = Network.TCPSocket() try: tcp.connect(Network.serverAddress) except: print "Could not connect to server." print "The server could be down. Try again later." tcp.close() return 1 print "Opening datagram socket..." udp = Network.UDPSocket() tcp.write('bindUDP %i\n' % udp.getsockname()[1]) newUser = User.User(tcp, udp) newUser.name = name newUser.pwd = pwd if(widget == self.create): newUser.isNewUser = True if(self.form.widget_guest.checkState == 1): newUser.isGuest = True self.destroy() return 1
def doLogin(self, widget): name = self.form.widget_user.text pwd = self.form.widget_pass.text Events.do('showConsole') print "Opening stream socket..." tcp = Network.TCPSocket() try: tcp.connect(Network.serverAddress) except: print "Could not connect to server." print "The server could be down. Try again later." tcp.close() return 1 print "Opening datagram socket..." udp = Network.UDPSocket() tcp.write('bindUDP %i\n' % udp.getsockname()[1]) newUser = User.User(tcp, udp) newUser.name = name newUser.pwd = pwd if (widget == self.create): newUser.isNewUser = True if (self.form.widget_guest.checkState == 1): newUser.isGuest = True self.destroy() return 1
def enter(self, widget): if (self.command.text != ''): s = string.split(self.command.text, maxsplit=1) self.command.setText('') self.setDirty() if (len(s) > 1): Events.do('command-' + s[0], s[1]) else: Events.do('command-' + s[0])
def enter(self, widget): if self.command.text != "": s = string.split(self.command.text, maxsplit=1) self.command.setText("") self.setDirty() if len(s) > 1: Events.do("command-" + s[0], s[1]) else: Events.do("command-" + s[0])
def handleInputUDP(self): packet = self.udp.read() if(not packet): return line = string.split(packet, maxsplit = 1) command = 'net ' + line[0] if(len(line) > 1): Events.do(command, self, line[1]) else: Events.do(command, self)
def handleInputUDP(self): packet = self.udp.read() if (not packet): return line = string.split(packet, maxsplit=1) command = 'net ' + line[0] if (len(line) > 1): Events.do(command, self, line[1]) else: Events.do(command, self)
def handleInputTCP(self): line = self.tcp.readline() if(not line): return line = line[:-1] line = string.split(line, maxsplit = 1) command = 'net ' + line[0] if(len(line) > 1): Events.do(command, self, line[1]) else: Events.do(command, self)
def handleInputTCP(self): line = self.tcp.readline() if (not line): return line = line[:-1] line = string.split(line, maxsplit=1) command = 'net ' + line[0] if (len(line) > 1): Events.do(command, self, line[1]) else: Events.do(command, self)
def run(): global root, window, system, input, events, done cm = ogre.ControllerManager() while (not done): input.capture() if (input.isKeyDown(ogre.KC_ESCAPE)): Events.do('quit') '''evt = events.pop() while(evt): print evt.mId evt = events.pop() if(input.mouseRelativeX or input.mouseRelativeY): cegui.System.getSingleton().injectMouseMove( \ input.mouseRelativeX * window.width, \ input.mouseRelativeY * window.height)''' root.renderOneFrame()
def run(): global root, window, system, input, events, done cm = ogre.ControllerManager() while(not done): input.capture() if(input.isKeyDown(ogre.KC_ESCAPE)): Events.do('quit') '''evt = events.pop() while(evt): print evt.mId evt = events.pop() if(input.mouseRelativeX or input.mouseRelativeY): cegui.System.getSingleton().injectMouseMove( \ input.mouseRelativeX * window.width, \ input.mouseRelativeY * window.height)''' root.renderOneFrame()
def login(user, command = ''): if(command == 'user'): print "Sending username..." if(user.isGuest): user.tcp.write('login guest ' + user.name + '\n') elif(user.isNewUser): user.tcp.write('login newuser ' + user.name + '\n') else: user.tcp.write('login user ' + user.name + '\n') elif(command == 'pass'): print "Sending password..." user.tcp.write('login pass ' + user.pwd + '\n') elif(command == 'ok'): print "Login successful!" Core.user = user Events.do('hideConsole') Events.do('start') elif(command == 'badpass'): print "Login incorrect. Bad user/password info." user.closeAll() init() elif(command == 'taken'): print "That username is taken. Please choose another." user.closeAll() init() elif(command == 'duplicate'): print "That user is already logged in. If you were disconnected allow a few minutes for your user name to reset." user.closeAll() init() elif(command[:6] == 'bindUDP'): print "Binding game datagram socket..." user.udp.connect((Network.serverAddress[0], int(command[8:]))) user.tcp.write('login bindUDP ' + user.udp.getsockname()[1]) else: print "An unknown error occured." init() user.closeAll()
def login(user, command=''): if (command == 'user'): print "Sending username..." if (user.isGuest): user.tcp.write('login guest ' + user.name + '\n') elif (user.isNewUser): user.tcp.write('login newuser ' + user.name + '\n') else: user.tcp.write('login user ' + user.name + '\n') elif (command == 'pass'): print "Sending password..." user.tcp.write('login pass ' + user.pwd + '\n') elif (command == 'ok'): print "Login successful!" Core.user = user Events.do('hideConsole') Events.do('start') elif (command == 'badpass'): print "Login incorrect. Bad user/password info." user.closeAll() init() elif (command == 'taken'): print "That username is taken. Please choose another." user.closeAll() init() elif (command == 'duplicate'): print "That user is already logged in. If you were disconnected allow a few minutes for your user name to reset." user.closeAll() init() elif (command[:6] == 'bindUDP'): print "Binding game datagram socket..." user.udp.connect((Network.serverAddress[0], int(command[8:]))) user.tcp.write('login bindUDP ' + user.udp.getsockname()[1]) else: print "An unknown error occured." init() user.closeAll()
def keyDown(evt): cegui.System.getSingleton().injectKeyDown(evt.key) cegui.System.getSingleton().injectChar(evt.keyChar) Events.do('keyDown', evt.key) print 'Generated keyDown event with key:' + evt.key
def write(self, text): self.oldout.write(text) self.logFile.write(text) self.logFile.flush() def __del__(self): self.logFile.close() print 'Starting up The Street client...' print 'Setting up client output logging...' clientLogger = Logger() print 'Executing startup scripts...' startScripts = glob.glob('StreetScripts/Startup/*.py') startScripts += glob.glob('StreetScripts/Client/Startup/*.py') startScripts += glob.glob('StreetScripts/Client/User/Startup/*.py') for script in startScripts: print '\t%s' % script execfile(script) print 'Initializing the client...' Events.do('init') print 'The Street is up and running.' Events.do('run') print "Shutting down the client..." print "Running shutdown events..." Events.do('cleanup') print "Client offline."
def render(): getRenderer().clear() Events.do('render') drawFPS()
def keyUp(evt): cegui.System.getSingleton().injectKeyUp(evt.key) Events.do('keyUp', evt.key)
def keyDown(event): Events.do("keyDown", event) if event.key == 27: Events.do("quit") return 1 return 0
self.logFile = file('clientlog.txt', 'w') def write(self, text): self.oldout.write(text) self.logFile.write(text) self.logFile.flush() def __del__(self): self.logFile.close() print 'Starting up The Street client...' print 'Setting up client output logging...' clientLogger = Logger() print 'Executing startup scripts...' startScripts = glob.glob('StreetScripts/Startup/*.py') startScripts += glob.glob('StreetScripts/Client/Startup/*.py') startScripts += glob.glob('StreetScripts/Client/User/Startup/*.py') for script in startScripts: print '\t%s' % script execfile(script) print 'Initializing the client...' Events.do('init') print 'The Street client is up and running.' Events.do('run') print "Shutting down the client..." print "Running shutdown events..." Events.do('quit') print "Client offline."
def mouseMoved(evt): global window x = evt.relX * window.width y = evt.relY * window.height cegui.System.getSingleton().injectMouseMove(x, y) Events.do('mouseMove', x, y)
def closeAll(self): Events.do('net logout', self) Network.TCPSocket.close(self.tcp) Network.UDPSocket.close(self.udp)
def keyDown(event): Events.do('keyDown', event) if (event.key == 27): Events.do('quit') return 1 return 0
def keyDown(event): Events.do('keyDown', event) if(event.key == 27): Events.do('quit') return 1 return 0
#along with The Street; if not, write to the Free Software #Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 import glob import signal import sys from StreetModules import Events from StreetModules.Server import Core def quit(signum, frame): Core.running = False signal.signal(signal.SIGINT, quit) print "Running startup scripts..." startScripts = glob.glob('StreetScripts/Startup/*.py') startScripts += glob.glob('StreetScripts/Server/Startup/*.py') for script in startScripts: print script execfile(script) print "Running initialization events..." Events.do('init') print "Server is up and running!" Events.do('run') print "Server shutting down..." print "Running shutdown events..." Events.do('quit') print "Server is offline."
def render(): getRenderer().clear() Events.do("render") drawFPS()