def test_connection(self, callback=None): if self._scktype == 'NS': self.send(msn.Message('PNG'), callback=callback) else: log.info( 'Not testing connection because this is not an NS socket.') callback.success()
def close(self): log.info('Closing %r', self) msn.MSNSocketBase.close(self) del self._q[:] if self._session_id is None: self.on_close() else: self.send(msn.Message('OUT'))
def main(): scktype = MsnHttpSocket sck = scktype() args = sck.connect_args_for('NS', ('messenger.hotmail.com', 1863)) print args sck.connect(*args) sck.send(msn.Message('VER', 'MSNP8', 'CVR0'), trid=True) app.toggle_crust() app.MainLoop()
def send_uux(self, message=None, mediainfo=None, url=None, callback=None): mtag = util.xml_tag.tag('Data') if message is not None: mtag.PSM._cdata = message else: mtag.PSM._cdata = '' if mediainfo is not None: mtag.CurrentMedia._cdata = mediainfo else: mtag.CurrentMedia._cdata = '' if url is not None: mtag.PSMUrl._cdata = url else: mtag.PSMUrl._cdata = '' message = mtag._to_xml(pretty=False).encode('utf-8') self.socket.send(msn.Message('UUX', payload=message), trid=True, callback=callback)
def close_when_done(self): ''' close_when_done() sends the 'OUT' command and then closes itself (when done!) ''' if self.rater is not None: self.rater.stop() self.rater = None if getattr(self, 'closed', False): return self.closed = True try: self.send(msn.Message('OUT')) except socket.error: pass try: self.close() except socket.error: pass