コード例 #1
0
    def lineReceived(self, line):
        """
        IMC2 -> Evennia

        Triggered when text is received from the IMC2 network. Figures out
        what to do with the packet. This deals with the following

        Args:
            line (str): Incoming text.

        """
        line = line.strip()

        if not self.is_authenticated:
            # we are not authenticated yet. Deal with this.
            self._imc_login(line)
            return

        #logger.log_infomsg("IMC2: RECV> %s" % line)

        # Parse the packet and encapsulate it for easy access
        packet = pck.IMC2Packet(self.mudname, packet_str=line)

        # Figure out what kind of packet we're dealing with and hand it
        # off to the correct handler.

        if packet.packet_type == 'is-alive':
            self.imc2_mudlist.update_mud_from_packet(packet)
        elif packet.packet_type == 'keepalive-request':
            # Don't need to check the destination, we only receive these
            # packets when they are intended for us.
            self.send_packet(pck.IMC2PacketIsAlive())
        elif packet.packet_type == 'ice-msg-b':
            self.data_out(text=line, packettype="broadcast")
        elif packet.packet_type == 'whois-reply':
            # handle eventual whois reply
            self._whois_reply(packet)
        elif packet.packet_type == 'close-notify':
            self.imc2_mudlist.remove_mud_from_packet(packet)
        elif packet.packet_type == 'ice-update':
            self.imc2_chanlist.update_channel_from_packet(packet)
        elif packet.packet_type == 'ice-destroy':
            self.imc2_chanlist.remove_channel_from_packet(packet)
        elif packet.packet_type == 'tell':
            # send message to identified player
            pass
コード例 #2
0
    def _imc_login(self, line):
        """
        Connect and identify to imc network as per the
        `self.auth_type` setting.

        Args:
            line (str): Incoming text.

        """

        if self.auth_type == "plaintext":
            # Only support Plain text passwords.
            # SERVER Sends: PW <servername> <serverpw> version=<version#> <networkname>

            logger.log_infomsg("IMC2: AUTH< %s" % line)

            line_split = line.split(' ')
            pw_present = line_split[0] == 'PW'
            autosetup_present = line_split[0] == 'autosetup'

            if "reject" in line_split:
                auth_message = _("IMC2 server rejected connection.")
                logger.log_infomsg(auth_message)
                return

            if pw_present:
                self.server_name = line_split[1]
                self.network_name = line_split[4]
            elif autosetup_present:
                logger.log_infomsg(_("IMC2: Autosetup response found."))
                self.server_name = line_split[1]
                self.network_name = line_split[3]
            self.is_authenticated = True
            self.sequence = int(time())

            # Log to stdout and notify over MUDInfo.
            logger.log_infomsg('IMC2: Authenticated to %s' %
                               self.factory.network)

            # Ask to see what other MUDs are connected.
            self._send_packet(pck.IMC2PacketKeepAliveRequest())
            # IMC2 protocol states that KeepAliveRequests should be followed
            # up by the requester sending an IsAlive packet.
            self._send_packet(pck.IMC2PacketIsAlive())
            # Get a listing of channels.
            self._send_packet(pck.IMC2PacketIceRefresh())
コード例 #3
0
ファイル: imc2.py プロジェクト: wty0512/evennia
 def _isalive(self):
     "Send an isalive packet."
     self._send_packet(pck.IMC2PacketIsAlive())