def send(self,stanza):
        """ Serialise stanza and put it on the wire. Assign an unique ID to it before send.
            Returns assigned ID."""
        if type(stanza) in [type(''), type(u'')]: return self._owner_send(stanza)
        if not isinstance(stanza,Protocol): _ID=None
        elif not stanza.getID():
            global ID
            ID+=1
            _ID=`ID`
            stanza.setID(_ID)
        else: _ID=stanza.getID()
        if self._owner._registered_name and not stanza.getAttr('from'): stanza.setAttr('from',self._owner._registered_name)
        if self._owner._route and stanza.getName()!='bind':
            to=self._owner.Server
            if stanza.getTo() and stanza.getTo().getDomain():
                to=stanza.getTo().getDomain()
            frm=stanza.getFrom()
            if frm.getDomain():
                frm=frm.getDomain()
            route=Protocol('route',to=to,frm=frm,payload=[stanza])
            stanza=route
        stanza.setNamespace(self._owner.Namespace)
        stanza.setParent(self._metastream)
        self._owner_send(stanza)
        return _ID
 Serialise stanza and put it on the wire. Assign an unique ID to it before send.
            Returns assigned ID.
chrome-cordova/gcmServer/xmpp/dispatcher.py