🚀 Launch 1.0

This commit is contained in:
2025-10-05 03:27:33 +08:00
parent 8ef05de8ad
commit bc23269778
3 changed files with 26 additions and 31 deletions

View File

@@ -29,14 +29,14 @@ class SolarNetworkConnect : JavaPlugin() {
private var messages: Map<String, String> = mapOf()
private fun handleWebSocketPacket(packet: WebSocketPacket) {
// logger.info("Received WebSocket packet: type=${packet.type}")
logger.info("Received WebSocket packet: type=${packet.type}")
if (packet.type.startsWith("messages") && packet.data != null) {
try {
when (packet.type) {
"messages.new" -> {
val message = SnChatMessage.fromJson(packet.data)
// Ignore automated accounts
if (message.sender.account.automatedId.isNullOrBlank()) return;
if (message.sender.account.automatedId.isNullOrBlank().not()) return;
// Only some rooms got synced
if (syncChatRooms.isEmpty() || syncChatRooms.contains(message.chatRoomId)) {
val roomName = message.chatRoom.name ?: "DM"

View File

@@ -2,6 +2,7 @@ package dev.solsynth.snConnect.services
import dev.solsynth.snConnect.models.WebSocketPacket
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
@@ -47,9 +48,10 @@ class SnService(private val baseUrl: String, val clientId: String, val clientSec
.build()
fun connect() {
logger.info("Attempting WebSocket connection to $url")
websocket = client.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket, response: Response) {
logger.info("WebSocket connection opened to $url")
logger.info("WebSocket connection opened successfully to $url")
}
override fun onMessage(webSocket: WebSocket, text: String) {