Beacon.activeClient.disconnect() doesn't work

  • Problem
  • Updated 4 years ago
Beacon.activeClient.disconnect() doesn't work for the FlashLongPoll client. It tries to call a function unembed() but that function doesn't seem to exist.

The following seems to work, though:


Beacon.FlashLongPoll.swfobject.removeSWF(Beacon.FlashLongPoll.containerId);
Photo of Fred Potter

Fred Potter

  • 9 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 2
Photo of cgbystrom

cgbystrom, Product Manager

  • 331 Posts
  • 17 Reply Likes
unembed() actually exists in the Flash object, it will internally disconnect the Flash SWF from the server. However, it didn't remove the SWF object itself from the DOM.

That's been fixed now and I added the line you suggested to the client.
You can use


Beacon.disconnect();


to disconnect the client from the server (regardless of transport method of course).

It's live now on the same URL, try it out and let me know if it doesn't work.
http://beaconpush.com/1/client.js
Photo of ArtA

Art

  • 4 Posts
  • 1 Reply Like
Hi!

I have the following set up (which I think is pretty straight forward):
When user enters the page, I call Beacon.connect(), then beacon.listen on a particular channel. Before messages are being sent to a channel, the number of users in the channel is checked to make sure there is someone present.
If I send message to a channel with zero listeners I will get a 'user offline' notification. This works fine, well, almost...
When user comes to the page, then leaves, he seems to be still registered as listener for a few minutes after. I do call Beacon.disconnect() when user leaves the page, but it does not seem to effectively disconnect the user and users in channel does not return zero. I would really appreciate some advice in this respect. Should I somehow 'un-listen'/leave the channel before calling Beacon.disconnect() or is there something else?
Photo of cgbystrom

cgbystrom, Product Manager

  • 331 Posts
  • 17 Reply Likes
The server will still see the user as online since the user may just be between page reloads (it's a feature). If you do like to force a logout of a user, see the REST API http://beaconpush.com/guide/rest-api/.
Photo of ArtA

Art

  • 4 Posts
  • 1 Reply Like
Thanks for replying. Ok, I suppose that makes sense, although I was sort of hoping that expressly calling disconnect() should actually disconnect user from service.

Anyhow, I tried using force_user_logout (I'm using beaconpush.php class), which is supposed to do the trick, but again it doesn't. User is still registered as online and listening to his channel for some minutes. Any other suggestions?
Photo of ArtA

Art

  • 4 Posts
  • 1 Reply Like
...in addition to above: the user seems to disconnect, so that messages are not being delivered to him, but he is still registered as online and listening to channel and that's a problem.
Photo of cgbystrom

cgbystrom, Product Manager

  • 331 Posts
  • 17 Reply Likes
If the user gets disconnected, he/she will be removed within 60 seconds if not getting connected again.