All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.javalin.websocket.WsRouter.kt Maven / Gradle / Ivy

The newest version!
package io.javalin.websocket

import io.javalin.config.RouterConfig
import io.javalin.security.RouteRole
import java.util.function.Consumer

class WsRouter(private val routerConfig: RouterConfig) {

    val wsExceptionMapper = WsExceptionMapper()
    val wsPathMatcher = WsPathMatcher()

    /** Add a WebSocket handler. */
    fun addHandler(handlerType: WsHandlerType, path: String, ws: Consumer, roles: Set) {
        wsPathMatcher.add(
            WsHandlerEntry(
                type = handlerType,
                path = path,
                routerConfig = routerConfig,
                wsConfig = WsConfig().apply { ws.accept(this) },
                roles = roles
            )
        )
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy