File: pb2server.py

package info (click to toggle)
foolscap 24.9.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,444 kB
  • sloc: python: 21,994; sh: 58; makefile: 52
file content (20 lines) | stat: -rw-r--r-- 493 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin/python

from twisted.internet import reactor
from foolscap.api import Referenceable, Tub

class MathServer(Referenceable):
    def remote_add(self, a, b):
        return a+b
    def remote_subtract(self, a, b):
        return a-b

myserver = MathServer()
tub = Tub(certFile="pb2server.pem")
tub.listenOn("tcp:12345")
tub.setLocation("localhost:12345")
url = tub.registerReference(myserver, "math-service")
print "the object is available at:", url

tub.startService()
reactor.run()