def on_receive(self, message): if not self.authenticated(): self.authenticate(message) return message = cellophane.escape(message) self.writeline('You say, "%s"' % message, 'orange'); for client in clients: if client is not self and client.authenticated: client.writeline('%s says, "%s"' % (self.name, message))
def authenticate(self, message): if self.name is None: # Use tornado's XHTML esacape to try to prevent XSS attacks. name = cellophane.escape(message) # This appends the name they gave to the end of out 'Please enter..' self.writeline(name) if name in [c.name for c in clients]: self.write('Sorry, that name is taken. Please enter a different username: '******'red') return # If we made it this far, they have given us a good name. self.name = name self.writeline('Please enter a password:'******'Welcome %s!' % self.name) return
def on_receive(self, message): message = cellophane.escape(message) self.writeline('You say, "%s"' % message, 'orange') for client in clients: if client is not self: client.writeline('Someone says, "%s"' % message)
def on_receive(self, message): message = cellophane.escape(message) self.writeline('You say, "%s"' % message, 'orange'); for client in clients: if client is not self: client.writeline('Someone says, "%s"' % message)