JDare / ClankBundle

A Symfony2 Bundle for use with Ratchet WebSocket Server
MIT License
131 stars 31 forks source link

Practical Usage #18

Closed abenz1267 closed 10 years ago

abenz1267 commented 10 years ago

i have a certain problem with my websocket functionality.

I have a header with 3 different areas, each with it's own template. My problem:

How can i use the opened session from area 1 in area 2 and 3.

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. ( do something ) });

I call this every time i need to work with the websocket server, e.g. publish, subscribe and unsubscribe to topics.

There has to be a workaround to use 1 session for all areas, cuz now everytime an area gets updated via ajax a new session is opened, and after a few events i end up having the same message in my javascript console for 10 times (and more, depending on the amount of events..), just because of all those connections.

Any idea?

Regards