Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 829
FreeWall Avatar asked Sep 30 '22 21:09

FreeWall


1 Answers

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

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

like image 166
FreeWall Avatar answered Oct 03 '22 04:10

FreeWall