Ejemplo n.º 1
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 recv_disconnect(self):
        """
        WebSocket was disconnected - leave the IRC channel.
        """
        quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING,
                                  settings.GNOTTY_PROJECT_URL)
        self.client.connection.quit(quit_message)
        self.disconnect(silent=True)
Ejemplo n.º 2
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.GNOTTY_VERSION_STRING,
                                  settings.GNOTTY_PROJECT_URL)
        self.client.connection.quit(quit_message)
        super(IRCNamespace, self).disconnect(*args, **kwargs)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)