예제 #1
0
    def publish(self, data):
        self.buffer += data
        packets, self.buffer = parse_packets(self.buffer)

        l = []
        for header, payload in packets:
            # send the packet to listeners of "packet-X"...they can choose what to listen for
            r = plugin_manager.publish("packet-%s" % packets_by_id[header], header, payload)
            l.append(r)

        def breakdown(the_list):
            data = ""
            for i in the_list:
                if isinstance(i, StringType):
                    data += i
                elif i == [None]:
                    continue
                elif isinstance(i, ListType):
                    data = breakdown(i)
                else:
                    data += chr(i[0]) + packet_def[i[0]].build(i[1])
            return data

        return breakdown(l)
예제 #2
0
 def dataReceived(self, data):
     if self.remote:
         raw = "".join(plugin_manager.publish("raw", data))
         self.remote.transport.write(raw)