12345678910111213141516171819202122232425262728293031323334 |
- package com.smcic.api.conference.controller;
- import cn.hutool.core.lang.UUID;
- import com.smcic.api.conference.service.impl.SSEService;
- import com.smcic.core.advice.NoAPIResponse;
- import org.springframework.http.MediaType;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
- import javax.annotation.Resource;
- import java.io.IOException;
- @Controller
- @RequestMapping("/conference")
- //@NoAPIResponse
- public class SSEController {
- @Resource
- private SSEService sseService;
- /*@GetMapping(path = "/photo-sse/{id}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- @NoAPIResponse
- public SseEmitter handleSse(@PathVariable("id") Long id) throws IOException {
- String uuid = UUID.fastUUID( ).toString( );
- SseEmitter sseEmitter = new SseEmitter(60 * 1000L); // 设置超时时间
- sseService.monitor(id, uuid, sseEmitter);
- sseEmitter.send(SseEmitter.event().name("hello").data("hello"));
- sseEmitter.onCompletion(() -> sseService.complate(id, uuid));
- return sseEmitter;
- }*/
- }
|