(self)
return encoded_packet
Encode the packet for transmission.

        If the packet contains binary elements, this function returns a list
        of packets where the first is the original packet with placeholders for
        the binary components and the remaining ones the binary attachments.
Encode the packet for transmission.
Encode the packet for transmission .
def encode(self):
        """Encode the packet for transmission.

        If the packet contains binary elements, this function returns a list
        of packets where the first is the original packet with placeholders for
        the binary components and the remaining ones the binary attachments.
        """
        encoded_packet = str(self.packet_type)
        if self.packet_type == BINARY_EVENT or self.packet_type == BINARY_ACK:
            data, attachments = self._deconstruct_binary(self.data)
            encoded_packet += str(len(attachments)) + '-'
        else:
            data = self.data
            attachments = None
        if self.namespace is not None and self.namespace != '/':
            encoded_packet += self.namespace + ','
        if self.id is not None:
            encoded_packet += str(self.id)
        if data is not None:
            encoded_packet += self.json.dumps(data, separators=(',', ':'))
        if attachments is not None:
            encoded_packet = [encoded_packet] + attachments
        return encoded_packet
def encode ( self ) : encoded_packet = str ( self . packet_type ) if self . packet_type == BINARY_EVENT or self . packet_type == BINARY_ACK : data , attachments = self . _deconstruct_binary ( self . data ) encoded_packet += str ( len ( attachments ) ) + '-' else : data = self . data attachments = None if self . namespace is not None and self . namespace != '/' : encoded_packet += self . namespace + ',' if self . id is not None : encoded_packet += str ( self . id ) if data is not None : encoded_packet += self . json . dumps ( data , separators = ( ',' , ':' ) ) if attachments is not None : encoded_packet = [ encoded_packet ] + attachments return encoded_packet