Hi everyone,
I'm trying to use the new component API and I'm not able to find how to manage the subscribe/unsubscribe/register/unregister.
import asyncio
from autobahn.asyncio.component import Component, run
from autobahn import wamp
comp = Component(
transports=[{
"type": "rawsocket",
"url": "/tmp/mysocket1",
"endpoint": {
"type": "unix",
"path": "/tmp/mysocket1"
}
}],
realm=u"realm1",
)
class MyClass:
def __init__(self, wamp_comp):
self._wamp = wamp_comp
self._session = None
self._wamp.on("join", self._initialize)
self._wamp.on("leave", self._uninitialize)
async def _initialize(self, session: wamp.ISession, details):
self._session = session
print("Subscribed")
await session.subscribe(handler=self.output, topic="com.test")
def _uninitialize(self, session, reason):
print(session, reason)
print("Lost WAMP connection")
self._session = None
async def output(self, value):
print("ok")
print(value)
await asyncio.sleep(0)
@comp.on_join
async def joined(session, details):
print("session ready")
count = 0
while True:
session.publish(topic="com.test", value="hello", count=count)
count += 1
print("hello")
await asyncio.sleep(5)
if __name__ == "__main__":
myobj = MyClass(comp)
run([comp])
But, until now I've not been able to get something working when I do session.*.
Right now, the output is:
2018-08-20T16:52:13 connecting once using transport type "rawsocket" over endpoint "unix"
2018-08-20T16:52:13 ApplicationSession started.
session ready
hello
Subscribed
hello
hello
^C2018-08-20T16:52:25 Shutting down due to SIGINT
So the subscriber do not work.
The aim of this is to be able to use the subscribe, unsubscribe register unregister without the decorators because the topics and so on will be defined at run time (this example is utterly simplified to stress my problem)(and also without the old ApplicationSession)
If someone has a little clue for me, it would be great.
Nicolas