FreeWall
FreeWall

Reputation: 119

PeerJS - Manually close the connection between peers

I use PeerJS for my P2P application (a multiplayer game). Everything is great (connection between peers, sending data), but I can't figure out how to manually close the connection between peers.

In docs are functions to "Close the connection to the server" or "Close the connection to the server and terminate all existing connections" (peer.disconnect(),peer.destroy()), but I just want to "terminate existing connections", not to "close the connection to the server".

I know I can handle connections in array and sending/receiving data just for peers with some status (like "connected" or "disconnected"), but other peers can sending data to me for overloading forexample (hackers > ddos...), so basically I want to have opportunity to give something like BAN.

Any ideas (sorry for bad english)?

SOLVED:

I must be really blind. There is DataConnection.close() function to close the connection between peers.

http://peerjs.com/docs/#dataconnection-close

Upvotes: 5

Views: 12873

Answers (1)

FreeWall
FreeWall

Reputation: 119

There is DataConnection.close() function to close the connection between peers.

http://peerjs.com/docs/#dataconnection-close

Upvotes: 5

Related Questions