source: doc/examples/pinger_s2s.tac @ 251:554782284e08

Last change on this file since 251:554782284e08 was 65:6936acbdb9bd, checked in by Ralph Meijer <ralphm@…>, 11 years ago

Add support for the XMPP Ping protocol.

Author: ralphm
Fixes #55.

This adds a whole bunch of examples around the ping protocol in different
settings for both the pinger and pingee: as a external server-side component,
as a standalone server with server-to-server connectivity and as a client.

Also updates the disco support to allow for non-deferred responses from
subprotocol handlers

File size: 1.2 KB
Line 
1"""
2An XMPP Ping client as a standalone server via s2s.
3
4This ping client accepts and initiates server-to-server connections using
5dialback and listens on C{127.0.1.1} with the domain set to the default
6hostname of this machine.
7"""
8
9import socket
10
11from twisted.application import service, strports
12from twisted.words.protocols.jabber.jid import JID
13from wokkel import component, server
14from pinger import Pinger
15
16# Configuration parameters
17
18S2S_PORT = 'tcp:5269:interface=127.0.1.1'
19SECRET = 'secret'
20DOMAIN = socket.gethostname()
21OTHER_DOMAIN = 'localhost'
22LOG_TRAFFIC = True
23
24
25# Set up the Twisted application
26
27application = service.Application("Pinger Server")
28
29router = component.Router()
30
31serverService = server.ServerService(router, domain=DOMAIN, secret=SECRET)
32serverService.logTraffic = LOG_TRAFFIC
33
34s2sFactory = server.XMPPS2SServerFactory(serverService)
35s2sFactory.logTraffic = LOG_TRAFFIC
36s2sService = strports.service(S2S_PORT, s2sFactory)
37s2sService.setServiceParent(application)
38
39pingerComponent = component.InternalComponent(router, DOMAIN)
40pingerComponent.logTraffic = LOG_TRAFFIC
41pingerComponent.setServiceParent(application)
42
43pingerHandler = Pinger(JID(OTHER_DOMAIN), JID(DOMAIN))
44pingerHandler.setHandlerParent(pingerComponent)
Note: See TracBrowser for help on using the repository browser.