def ApplicationDatagram(self, app, stream, text):
        """Called when a datagram is received over a stream."""

        # we should only proceed if we are in UDP mode
        if stype != socket.SOCK_DGRAM:
            return

        # decode the data
        data = base64.decodestring(text)

        # open an UDP socket
        sock = socket.socket(type=stype)

        # send the data
        try:
            sock.sendto(data, addr)
        except socket.error, e:
            print 'error: %s' % e
Called when a datagram is received over a stream.