dev_v1.0.1
liu 2 years ago
parent 5f283f24e4
commit acf463cd48

@ -55,10 +55,12 @@
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.9</version>
<version>3.0.3</version>
</dependency>
</dependencies>
</project>

@ -37,4 +37,21 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -2,13 +2,14 @@ package com.supervision.controller;
import com.supervision.websocket.cache.WebSocketUserCache;
import io.swagger.annotations.Api;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import javax.annotation.Resource;
import java.io.IOException;
@Api(tags = "问诊")
@ -16,11 +17,18 @@ import java.io.IOException;
@RequestMapping("/ask/")
public class AskController {
@RequestMapping("/send")
public void sendMessage(String message,String id) throws IOException {
WebSocketSession session = WebSocketUserCache.getSession(id);
@GetMapping("/sendMessage")
public void sendMessage(String message, String sessionId) throws IOException {
WebSocketSession session = WebSocketUserCache.getSession(sessionId);
session.sendMessage(new TextMessage(message));
}
@PostMapping("/receiveVoiceFile")
public void receiveVoiceFile(MultipartFile file){
long size = file.getSize();
System.out.println(size);
}
}

@ -4,7 +4,6 @@ import com.supervision.websocket.handler.AskWebSocketHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
@ -13,7 +12,7 @@ public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(askWebSocketHandler(), "/websocket")
registry.addHandler(askWebSocketHandler(), "/askSocket")
.setAllowedOrigins("*");
}

@ -1,6 +1,8 @@
#服务器端口
server:
port: 8899
servlet:
context-path: /
spring:
profiles:

Loading…
Cancel
Save