CoolFace
Apppublic

sakthivikram/geo-location

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
IssueWebSocketController.java44 linesDownload Raw Back to websocket
1package com.georeport.websocket;2 3import org.springframework.messaging.handler.annotation.MessageMapping;4import org.springframework.messaging.handler.annotation.SendTo;5import org.springframework.messaging.simp.annotation.SendToUser;6import org.springframework.stereotype.Controller;7 8import java.util.Map;9 10/**11 * WebSocket Controller for real-time messaging.12 * Handles client-to-server WebSocket messages.13 */14@Controller15public class IssueWebSocketController {16 17    /**18     * Handle subscription to issues topic19     * Client sends: /app/subscribe20     * Response sent to: /topic/issues21     */22    @MessageMapping("/subscribe")23    @SendTo("/topic/issues")24    public Map<String, Object> subscribeToIssues(Map<String, Object> message) {25        return Map.of(26                "eventType", "SUBSCRIPTION_CONFIRMED",27                "message", "Successfully subscribed to issue updates",28                "timestamp", System.currentTimeMillis());29    }30 31    /**32     * Handle ping messages for connection keepalive33     * Client sends: /app/ping34     * Response sent to: /user/queue/pong35     */36    @MessageMapping("/ping")37    @SendToUser("/queue/pong")38    public Map<String, Object> handlePing(Map<String, Object> message) {39        return Map.of(40                "eventType", "PONG",41                "timestamp", System.currentTimeMillis());42    }43}44