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

dev.robocode.tankroyale.server.connection.MultiServerWebSocketObserver.kt Maven / Gradle / Ivy

package dev.robocode.tankroyale.server.dev.robocode.tankroyale.server.connection

import dev.robocode.tankroyale.server.Server
import org.java_websocket.WebSocket
import java.net.InetAddress
import java.net.InetSocketAddress

class MultiServerWebSocketObserver(observer: IClientWebSocketObserver) {

    private val loopbackServerWebSocketObserver = ServerWebSocketObserver(InetSocketAddress(Server.port), observer)
    private val localhostServerWebSocketObserver = ServerWebSocketObserver(InetSocketAddress(InetAddress.getLocalHost(), Server.port), observer)

    fun start() {
        loopbackServerWebSocketObserver.run()
        localhostServerWebSocketObserver.run()
    }

    fun broadcast(clientSockets: Collection, message: String) {
        localhostServerWebSocketObserver.broadcast(message, clientSockets)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy