Save the stream ID when the stream starts.

This commit is contained in:
Lance Stout 2011-08-06 00:44:32 -07:00
parent 5be5b8c02b
commit e83fae3a6f
2 changed files with 14 additions and 1 deletions

View file

@ -138,6 +138,17 @@ class BaseXMPP(XMLStream):
register_stanza_plugin(Message, Nick) register_stanza_plugin(Message, Nick)
register_stanza_plugin(Message, HTMLIM) register_stanza_plugin(Message, HTMLIM)
def start_stream_handler(self, xml):
"""
Save the stream ID once the streams have been established.
Overrides XMLStream.start_stream_handler.
Arguments:
xml -- The incoming stream's root element.
"""
self.stream_id = xml.get('id', '')
def process(self, *args, **kwargs): def process(self, *args, **kwargs):
""" """
Overrides XMLStream.process. Overrides XMLStream.process.

View file

@ -115,11 +115,13 @@ class ComponentXMPP(BaseXMPP):
Once the streams are established, attempt to handshake Once the streams are established, attempt to handshake
with the server to be accepted as a component. with the server to be accepted as a component.
Overrides XMLStream.start_stream_handler. Overrides BaseXMPP.start_stream_handler.
Arguments: Arguments:
xml -- The incoming stream's root element. xml -- The incoming stream's root element.
""" """
BaseXMPP.start_stream_handler(self, xml)
# Construct a hash of the stream ID and the component secret. # Construct a hash of the stream ID and the component secret.
sid = xml.get('id', '') sid = xml.get('id', '')
pre_hash = '%s%s' % (sid, self.secret) pre_hash = '%s%s' % (sid, self.secret)