Evren Bingøl
Evren Bingøl

Reputation: 1725

xsockets close event

Does any one know how to close an xsockets socket.

There is no api for server or client side to show how to close a socket.

There is an event one can bind to "close" on client side but it says that "this will get called when server closes the websocket"

How can you close the websocket from the client side or from the serverside.

I extracted the socket object from xsocketcontroller and called close() on it but no luck. client side close did not get called.

Upvotes: 1

Views: 408

Answers (1)

Uffe
Uffe

Reputation: 2275

This is not well in the documentation I´m afraid. Will fix that a.s.a.p

You have a few options. The first ones is how to close the connection from the client. However, you will also see in the example code that you can call close from serverside.

  1. Just kill the connection in the client by calling close() on your instance.
  2. Trigger/Publish a serverside event that will disconnect. This would be more controlled, and let you clean up stuff.
  3. Call the disconnect from the server on a client. Forcing a close!

See the examples at pastebin:

HTML: HowTo Close From JavaScript

Controller: HowTo Close From Server (or handle close request from client)

Upvotes: 1

Related Questions