示例#1
0
 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)
示例#2
0
文件: server.py 项目: McDoku/denigma
 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)
示例#3
0
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)
示例#4
0
文件: server.py 项目: McDoku/denigma
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)