Changeset 35:2866eaae775f in ralphm-patches
- Timestamp:
- Feb 12, 2010, 12:01:52 PM (12 years ago)
- Branch:
- default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
client_service_example.patch
r34 r35 1 diff -r a0bcf2e586ecdoc/examples/client_service.tac1 diff -r 0a3d1655a3e5 doc/examples/client_service.tac 2 2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3 +++ b/doc/examples/client_service.tac Fri Feb 12 09:50:08 2010 +01004 @@ -0,0 +1,4 0@@3 +++ b/doc/examples/client_service.tac Fri Feb 12 11:55:08 2010 +0100 4 @@ -0,0 +1,41 @@ 5 5 +from twisted.application import service 6 6 +from twisted.internet import defer … … 8 8 +from wokkel.client import ClientService 9 9 +from wokkel.generic import FallbackHandler 10 +from wokkel.xmppim import Roster Protocol10 +from wokkel.xmppim import RosterServerProtocol 11 11 + 12 12 +import socket 13 13 +domain = socket.gethostname() 14 14 + 15 +class StaticRoster(Roster Protocol):15 +class StaticRoster(RosterServerProtocol): 16 16 + 17 17 + def __init__(self): 18 + RosterServerProtocol.__init__(self) 18 19 + self.roster = {'ralphm': 19 20 + [{'jid': 'intosi@' + domain, … … 40 41 +clientService = ClientService(domain, 5224) 41 42 +clientService.logTraffic = True 42 + clientService.addHandler(FallbackHandler())43 + clientService.addHandler(StaticRoster())43 +FallbackHandler().setHandlerParent(clientService) 44 +StaticRoster().setHandlerParent(clientService) 44 45 +clientService.setServiceParent(application) -
xmpp_client_service.patch
r34 r35 1 1 diff -r 67a42d8a1c73 wokkel/client.py 2 2 --- a/wokkel/client.py Fri Feb 12 09:31:19 2010 +0100 3 +++ b/wokkel/client.py Fri Feb 12 09:37:28 2010 +0100 4 @@ -18,10 +18,11 @@ 3 +++ b/wokkel/client.py Fri Feb 12 11:46:41 2010 +0100 4 @@ -17,11 +17,12 @@ 5 from twisted.names.srvconnect import SRVConnector 5 6 from twisted.python import log 6 7 from twisted.words.protocols.jabber import client, error, sasl, xmlstream 7 8 -from twisted.words.protocols.jabber.jid import internJID as JID 8 9 -from twisted.words.xish import domish 10 +from twisted.words.protocols.jabber.jid import JID, internJID 9 11 +from twisted.words.xish import domish, utility 10 12 … … 12 14 -from wokkel.subprotocols import StreamManager 13 15 +from wokkel.compat import XmlStreamServerFactory 14 +from wokkel.subprotocols import StreamManager, XMPPHandlerCo ntainer16 +from wokkel.subprotocols import StreamManager, XMPPHandlerCollection 15 17 16 18 NS_CLIENT = 'jabber:client' 17 19 18 @@ -350,3 +351,13 0@@20 @@ -350,3 +351,132 @@ 19 21 reply['id'] = iq['id'] 20 22 reply.addElement((client.NS_XMPP_SESSION, 'session')) … … 44 46 + 45 47 + 46 +class ClientService(XMPPHandlerCo ntainer, service.Service):48 +class ClientService(XMPPHandlerCollection, service.Service): 47 49 + """ 48 50 + Service for accepting XMPP client connections. … … 58 60 + makes it easier to create adapters. 59 61 + 60 + As an L{xmlstream.XMPPHandlerCo ntainer}, this service creates a fake XML62 + As an L{xmlstream.XMPPHandlerCollection}, this service creates a fake XML 61 63 + stream that is passed to the XMPP subprotocol handlers. The received 62 64 + stanzas from the incoming client connections are passed on to the handlers … … 72 74 + self.port = port 73 75 + 74 + self.factory = XmlStreamServerFactory(XMPPClientListenAuthenticator, 75 + self.domain) 76 + def authenticatorFactory(): 77 + return XMPPClientListenAuthenticator(self.domain) 78 + 79 + self.factory = XmlStreamServerFactory(authenticatorFactory) 76 80 + self.factory.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, 77 81 + self.makeConnection) … … 81 85 + self.streams = {} 82 86 + 83 + XMPPHandlerCo ntainer.__init__(self)87 + XMPPHandlerCollection.__init__(self) 84 88 + 85 89 + … … 141 145 + """ 142 146 + 143 + destination = JID(element["to"]).full()147 + destination = internJID(element["to"]).full() 144 148 + 145 149 + if destination not in self.streams:
Note: See TracChangeset
for help on using the changeset viewer.