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

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

@ -37,4 +37,21 @@
</dependencies> </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> </project>

@ -2,13 +2,14 @@ package com.supervision.controller;
import com.supervision.websocket.cache.WebSocketUserCache; import com.supervision.websocket.cache.WebSocketUserCache;
import io.swagger.annotations.Api; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.WebSocketSession;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@Api(tags = "问诊") @Api(tags = "问诊")
@ -16,11 +17,18 @@ import java.io.IOException;
@RequestMapping("/ask/") @RequestMapping("/ask/")
public class AskController { public class AskController {
@RequestMapping("/send") @GetMapping("/sendMessage")
public void sendMessage(String message,String id) throws IOException { public void sendMessage(String message, String sessionId) throws IOException {
WebSocketSession session = WebSocketUserCache.getSession(id); WebSocketSession session = WebSocketUserCache.getSession(sessionId);
session.sendMessage(new TextMessage(message)); 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler; 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.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
@ -13,7 +12,7 @@ public class WebSocketConfig implements WebSocketConfigurer {
@Override @Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(askWebSocketHandler(), "/websocket") registry.addHandler(askWebSocketHandler(), "/askSocket")
.setAllowedOrigins("*"); .setAllowedOrigins("*");
} }

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

Loading…
Cancel
Save