-
Notifications
You must be signed in to change notification settings - Fork 4
ping
CaffeinatedRat edited this page Apr 3, 2013
·
1 revision
This method pings the Minecraft WebSocketServer.
The following is the method signature:
CaffeinatedRat.Minecraft.WebSocketServices.prototype.ping(parameters)
The following parameters are available for this method:
This is a callback function that is called when the client-side library has made a successful connection with the WebSocketServer.
- Value: function() { }
- Default: Do nothing.
This is a callback function that is called when the client-side library has made a connection has been lost with the WebSocketServer.
- Value: function() { }
- Default: Do nothing.
This is a callback function that is called when there is a time update for the WebSocketServer.
- Value: function(serverTime) { }
- Default: Do nothing.
This parameter is used to determine the amount of time in milliseconds that the ping service will ping the WebSocketServer. This replaces the pingInterval specified during instantiation.
- Value: 0 - 2147483647
- Default: 15000 (milliseconds)
//Respond to a server connection. function pingConnected() { console.log("We're online!"); } //Respond to a server disconnection. function pingDisconnected() { console.log("We've lost connection! Pancake!"); } //Respond to the server time update event. function pingServerTime(serverTime) { console.log("The time is " + serverTime + " on the server."); } //Ping the server. wss.ping({ connectedCallback: pingConnected, disconnectedCallback: pingDisconnected, serverTimeCallback: pingServerTime });