def on_start(self, host, port, channel, nickname, password): """A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) self.spawn(self.client.start)
class IRCNamespace(BaseNamespace): """gevent-socketio namespace that's bridged with an IRC client.""" def on_start(self, host, port, channel, nickname, password): """A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) self.spawn(self.client.start) def on_message(self, message): """Message received from a WebSocket - send it to the IRC channel.""" if hasattr(self, 'client'): self.client.emit_message(message) def disconnect(self, *args, **kwargs): """WebSocket was disconnected - leave the IRC channel.""" quit_message = '%s %s' % (settings.CHAT_VERSION_STRING, settings.CHAT_PROJECT_URL) self.client.connection.quit(quit_message) super(IRCNamespace, self).disconnect(*args, **kwargs)