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.
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./docs/#dataconnection-close
Share Improve this question edited Sep 11, 2014 at 22:59 FreeWall asked Sep 11, 2014 at 21:36 FreeWallFreeWall 1191 gold badge3 silver badges9 bronze badges 2- 2 Go ahead and post an answer to your own question. – Benjamin Trent Commented Sep 12, 2014 at 12:32
- Can you explain how to disconnect the peer connection. [peerjs./docs/#dataconnection-close] link is not found – Sakkeer A Commented Mar 6, 2019 at 8:01
1 Answer
Reset to default 5There is DataConnection.close()
function to close the connection between peers.
http://peerjs./docs/#dataconnection-close