Open abenz1267 opened 10 years ago
@JDare no tip/idea?
If you're talking about accessing a web session on the socket, try this documentation: https://github.com/JDare/ClankBundle/blob/master/Resources/docs/SessionSetup.md
@JDare Hi,
no, i'm talking about accessing the Autobahn session opened when calling "Clank.connect". "//session is an Autobahn JS WAMP session." -> this session.
F.e: I have a page with a dynamic header -> multiple twig templates, but all those templates need to use the same session, cuz otherwise i'm opening a new Autobahn session for every new websocket call.
@JDare When reloading the page, all connections get closed, as they should. The header f.e. establishes a websocket connection, subscribing to different topics.
My header consists of like...3 different dynamic parts. F.e. if i need to publish to a topic in section 2, i have to establish a new connection, but i'd be much more pratical to use the connection/session opened in the 1. section of the header.... which always gets opened.
What i'd need to know is how to use the already opened connection.
Cmon, no one knows how to solve this? I mean..it should be possible to use the same connection to publish/subscribe/unsubscribe WITHOUT calling
var _CLANK_URI = "ws://{{ clank_host }}:{{ clank_port }}";
var myClank = Clank.connect(_CLANK_URI);
myClank.on("socket/connect", function(session){
//session is an Autobahn JS WAMP session.
});
evertime, since it always opens ANOTHER connection, instead of using the already opened one.
@JDare
All i'd need is the opened "Autobahn JS WAMP session", so i can call f.e: session.publish("acme/channel", {msg: "This is a message!"});
without opening a new connection ( cuz a connection is opened already...).
From the autobahn API reference:
"Connection.session Returns an instance of autobahn.Session if there is a session currently running on the connection."
So how can i access this session within clank? Clank can obv. start a session when connecting, but how to get an already started session on that connection?
Regards
In my js, I have done:
clank.on('socket/connect', function (session) {
window['clankSession'] = session;
});
So I can access session everywhere (subscribe, publish...) once the session is opened by using:
clankSession.publish("acme/channel", {msg: "This is a message!"});
Hi,
how can i access a session that's currently opened on the connection?
Regards