I have done a client like this SomeClient, which talk with a WAMP v1 server.
What I'm unable to do, as you can see on line 25, is to call the SomeClient.i_need_to_call_this method from the HTTPServer class.
from twisted.internet import reactor
from twisted.web import server, resource
from autobahn.wamp1.protocol import WampClientFactory, WampCraClientProtocol
from autobahn.twisted.websocket import connectWS
class SomeClient(WampCraClientProtocol):
def __init__(self):
pass
def doSomething(self, something):
return something
def i_need_to_call_this(self):
d = self.call("http://somewhere")
d.addCallback(self.doSomething)
class HTTPServer(resource.Resource):
isLeaf = True
def render_GET(self, request):
request.setHeader("content-type", "application/json")
result = "Here i need to call SomeClient.i_need_to_call_this and render the result"
return result
if __name__ == '__main__':
factory = WampClientFactory("wss://someurl")
factory.protocol = SomeClient
connectWS(factory)
reactor.listenTCP(8080, server.Site(HTTPServer()))
reactor.run()