Код: Выделить всё
curl --request GET \
--url 'http://localhost:8080/api/shipMovementSubscribe?=' \
--header 'Content-Type: text/event-stream' \
--header 'User-Agent: insomnia/11.6.1' \
--header 'gameLink: someText'
Код: Выделить всё
< HTTP/1.1 415 Unsupported Media Type
< Server: Apache-Coyote/1.1
< Date: Mon, 13 Oct 2025 12:56:00 GMT
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: origin, content-type, accept, authorization
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
< Access-Control-Max-Age: 1209600
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Content-Length: 0
Код: Выделить всё
public class RestService implements GameApi {
public static Logger LOG = LoggerFactory.getLogger(RestService.class);
private static final Map playersConnectionsMap = new HashMap();
@Resource
private MasterRepository masterRepository;
@Resource
private GameRepository gameRepository;
@Resource
ObjectMapper objectMapper;
@Context
private Sse sse;
@GET
@Path("/shipMovementSubscribe")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void shipMovementSubscribe(@Context SseEventSink sseEventSink
, @Context Sse sse, MoveChipDTO moveChipDTO
, @Context HttpHeaders headers) {
UUID gameId = GAME_ID;
if (!playersConnectionsMap.containsKey(gameId)) {
playersConnectionsMap.put(gameId, sse.newBroadcaster());
}
playersConnectionsMap.get(gameId).register(sseEventSink);
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ibe-method
Мобильная версия