File tree Expand file tree Collapse file tree
app/src/main/java/com/sameerasw/airsync/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,6 +425,10 @@ object WebSocketMessageHandler {
425425
426426 private fun handlePing (context : Context ) {
427427 try {
428+ // Reply immediately with lightweight pong message to keep session active
429+ val pongJson = " {\" type\" :\" pong\" ,\" data\" :{}}"
430+ WebSocketUtil .sendMessage(pongJson)
431+
428432 // Respond to ping with current device status to keep connection alive
429433 // We must force sync here because the server expects a response to every ping
430434 SyncManager .checkAndSyncDeviceStatus(context, forceSync = true )
Original file line number Diff line number Diff line change @@ -76,10 +76,6 @@ object WebSocketUtil {
7676 .connectTimeout(15 , TimeUnit .SECONDS )
7777 .writeTimeout(10 , TimeUnit .SECONDS )
7878 .readTimeout(0 , TimeUnit .SECONDS ) // Keep connection alive
79- .pingInterval(
80- 20 ,
81- TimeUnit .SECONDS
82- ) // Send ping every 20 seconds
8379 .build()
8480 }
8581
You can’t perform that action at this time.
0 commit comments