Skip to content
Snippets Groups Projects
Commit 711f515f authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#196 - Add ping method to keep connection to clients active

parent bb046666
Branches
Tags
No related merge requests found
...@@ -15,6 +15,7 @@ class WebSocketHandler { ...@@ -15,6 +15,7 @@ class WebSocketHandler {
private val sessions = new ConcurrentLinkedQueue[Session] private val sessions = new ConcurrentLinkedQueue[Session]
private val methods: Map[String, MethodExecutable] = Map( private val methods: Map[String, MethodExecutable] = Map(
"ping" -> new PingMethod,
"project-list" -> new ProjectListMethod, "project-list" -> new ProjectListMethod,
"project-current" -> new ProjectCurrentMethod, "project-current" -> new ProjectCurrentMethod,
"project-open" -> new ProjectOpenMethod, "project-open" -> new ProjectOpenMethod,
......
package de.tobias.playpad.plugin.api.websocket.methods
import com.google.gson.JsonObject
import de.tobias.playpad.plugin.api.websocket.MethodExecutable
import de.tobias.playpad.plugin.api.websocket.message.Message
import org.eclipse.jetty.websocket.api.Session
class PingMethod extends MethodExecutable {
override def execute(session: Session, message: Message): JsonObject = {
val response = new JsonObject()
response.addProperty("pong", System.currentTimeMillis())
response
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment