source: ralphm-patches/client_service_example.patch @ 34:e46c5701df9e

Last change on this file since 34:e46c5701df9e was 34:e46c5701df9e, checked in by Ralph Meijer <ralphm@…>, 12 years ago

Add a bunch of new patches.

File size: 1.5 KB
RevLine 
[34]1diff -r a0bcf2e586ec doc/examples/client_service.tac
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 +0100
4@@ -0,0 +1,40 @@
5+from twisted.application import service
6+from twisted.internet import defer
7+
8+from wokkel.client import ClientService
9+from wokkel.generic import FallbackHandler
10+from wokkel.xmppim import RosterProtocol
11+
12+import socket
13+domain = socket.gethostname()
14+
15+class StaticRoster(RosterProtocol):
16+
17+    def __init__(self):
18+        self.roster = {'ralphm':
19+                           [{'jid': 'intosi@' + domain,
20+                             'name': 'Intosi',
21+                             'subscription': 'both',
22+                             'ask': None,
23+                             'groups': ['Friends']
24+                            },
25+                            {'jid': 'termie@' + domain,
26+                             'name': 'termie',
27+                             'subscription': 'both',
28+                             'ask': None,
29+                             'groups': []
30+                            }],
31+                       'test':
32+                            [
33+                            ]}
34+
35+    def getRoster(self, entity):
36+        return defer.succeed(self.roster[entity.user])
37+
38+
39+application = service.Application("Jabber server")
40+clientService = ClientService(domain, 5224)
41+clientService.logTraffic = True
42+clientService.addHandler(FallbackHandler())
43+clientService.addHandler(StaticRoster())
44+clientService.setServiceParent(application)
Note: See TracBrowser for help on using the repository browser.