コード例 #1
0
    def __init__(self, jid, host, password, port=5222):
        self._jid, self._host, self._port = jid, host, port
        self._encoding = 'utf-8'
        self._io_sync = threading.Lock()
        self._closed = threading.Event()

        handlers = {
            ('iq', 'get'): self.handle_iq_get,
            ('iq', 'set'): self.handle_iq_set,
            ('message', 'normal'): self.handle_message,
            ('message', 'chat'): self.handle_message,
            ('presence', None): self.handle_presence_available,
            ('presence', 'unavailable'): self.handle_presence_unavailable,
            ('presence', 'error'): self.handle_presence_unavailable,
            ('presence', 'subscribe'): self.handle_presence_control,
            ('presence', 'subscribed'): self.handle_presence_control,
            ('presence', 'unsubscribe'): self.handle_presence_control,
            ('presence', 'unsubscribed'): self.handle_presence_control,
        }
        XmppStream.__init__(self,
                            self._jid,
                            handlers,
                            encoding=self._encoding,
                            password=password,
                            prefer_tls=True)
コード例 #2
0
ファイル: xmppstatus.py プロジェクト: Tallefer/jabrss
    def connect(self):
        # resolve addresses manually for compatibility with Python 2.5
        # which doesn't support create_connection
        exc = socket.gaierror(-2, 'Name or service not known')
        for ai in socket.getaddrinfo(self._host, self._port, socket.AF_UNSPEC, socket.SOCK_STREAM):
            try:
                exc = None
                self._sock = socket.socket(ai[0], ai[1], ai[2])
                self._sock.settimeout(30)
                self._sock.connect(ai[4])
                break
            except socket.error as e:
                exc = e

        if exc != None:
            raise exc

        self._sock.settimeout(600)
        XmppStream.connect(self)
コード例 #3
0
ファイル: xmppstatus.py プロジェクト: Tallefer/jabrss
    def __init__(self, jid, host, password, port=5222):
        self._jid, self._host, self._port = jid, host, port
        self._encoding = 'utf-8'
        self._io_sync = threading.Lock()
        self._closed = threading.Event()

        self._event_queue = []
        self._event_queue_cond = threading.Condition()
        self._term, self._term_flag = threading.Event(), False

        handlers = {
            ('message', 'normal') : self.handle_message,
            ('message', 'chat') : self.handle_message,
            ('presence', None) : self.handle_presence_available,
            ('presence', 'unavailable') : self.handle_presence_unavailable,
            ('presence', 'error') : self.handle_presence_unavailable,
            }
        XmppStream.__init__(self, self._jid, handlers,
                            encoding=self._encoding, password=password,
                            prefer_tls=True)
コード例 #4
0
ファイル: xmppecho.py プロジェクト: vitalyster/jabrss
    def __init__(self, jid, host, password, port=5222):
        self._jid, self._host, self._port = jid, host, port
        self._encoding = 'utf-8'
        self._io_sync = threading.Lock()
        self._closed = threading.Event()

        handlers = {
            ('iq', 'get') : self.handle_iq_get,
            ('iq', 'set') : self.handle_iq_set,
            ('message', 'normal') : self.handle_message,
            ('message', 'chat') : self.handle_message,
            ('presence', None) : self.handle_presence_available,
            ('presence', 'unavailable') : self.handle_presence_unavailable,
            ('presence', 'error') : self.handle_presence_unavailable,
            ('presence', 'subscribe') : self.handle_presence_control,
            ('presence', 'subscribed') : self.handle_presence_control,
            ('presence', 'unsubscribe') : self.handle_presence_control,
            ('presence', 'unsubscribed') : self.handle_presence_control,
            }
        XmppStream.__init__(self, self._jid, handlers,
                            encoding=self._encoding, password=password,
                            prefer_tls=True)
コード例 #5
0
ファイル: xmppecho.py プロジェクト: vitalyster/jabrss
 def starttls_proceed(self, elem):
     self._sock = ssl.wrap_socket(self._sock, do_handshake_on_connect=False)
     self._sock.do_handshake()
     XmppStream.connect(self)
コード例 #6
0
ファイル: xmppecho.py プロジェクト: vitalyster/jabrss
 def connect(self):
     self._sock = socket.create_connection((self._host, self._port))
     XmppStream.connect(self)
コード例 #7
0
ファイル: xmppstatus.py プロジェクト: Tallefer/jabrss
 def starttls_proceed(self, elem):
     self._sock = ssl.wrap_socket(self._sock, do_handshake_on_connect=False)
     self._sock.do_handshake()
     XmppStream.connect(self)
コード例 #8
0
 def connect(self):
     self._sock = socket.create_connection((self._host, self._port))
     XmppStream.connect(self)