okay so this should work again, but it's a lot more cursed now (Main.Kt#249)
This commit is contained in:
parent
e63b07ed69
commit
f61a115e32
|
@ -12,9 +12,7 @@ import io.ktor.features.CallLogging
|
|||
import io.ktor.features.ContentNegotiation
|
||||
import io.ktor.html.respondHtml
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.URLProtocol
|
||||
import io.ktor.http.cio.websocket.*
|
||||
import io.ktor.http.isSecure
|
||||
import io.ktor.jackson.jackson
|
||||
import io.ktor.response.respondRedirect
|
||||
import io.ktor.response.respondText
|
||||
|
@ -22,7 +20,6 @@ import io.ktor.routing.get
|
|||
import io.ktor.routing.routing
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.server.netty.Netty
|
||||
import io.ktor.util.url
|
||||
import io.ktor.websocket.DefaultWebSocketServerSession
|
||||
import io.ktor.websocket.WebSockets
|
||||
import io.ktor.websocket.webSocket
|
||||
|
@ -33,7 +30,6 @@ import kotlinx.html.*
|
|||
import org.slf4j.event.Level
|
||||
import redis.clients.jedis.JedisPool
|
||||
import redis.clients.jedis.Protocol
|
||||
import java.net.URI
|
||||
import java.time.Duration
|
||||
import java.time.LocalDateTime
|
||||
|
||||
|
@ -250,10 +246,7 @@ fun Application.module() {
|
|||
}
|
||||
|
||||
script {
|
||||
val wsurl = call.url {
|
||||
protocol = if (protocol.isSecure()) URLProtocol.WSS else URLProtocol.WS
|
||||
path("/ws")
|
||||
}
|
||||
val wsurl = baseURL.replaceFirst("http", "ws") + "/ws?name=$who&type=${what.name}"
|
||||
unsafe {
|
||||
//language=JavaScript
|
||||
+"""
|
||||
|
@ -325,6 +318,7 @@ fun Application.module() {
|
|||
for (frame in this.incoming.mapNotNull { it as? Frame.Text }) {
|
||||
try {
|
||||
val msg: RecvMsg = mapper.readValue(frame.readText())
|
||||
println(msg)
|
||||
val send = Message(what.let { if (it == Types.ask) who else "someone" }, msg.message)
|
||||
mms.addMessageTo(who, send)
|
||||
mms.getSocketsFor(who).forEach {
|
||||
|
@ -355,8 +349,10 @@ fun Application.module() {
|
|||
}
|
||||
}
|
||||
|
||||
val baseURL = System.getenv("SQA_BASE_URL") ?: "http://localhost:8080"
|
||||
|
||||
fun main() {
|
||||
|
||||
val host: String? = System.getenv("SQA_REDIS_HOST")
|
||||
val port: Int? = System.getenv("SQA_REDIS_PORT")?.toIntOrNull()
|
||||
mms = if (host != null) {
|
||||
|
|
Loading…
Reference in a new issue