kaiyu
2020-09-30 786577d75f2221e95d5d53e60338cc20cc82df71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.moral.config;
 
import com.moral.service.DeviceService;
import com.moral.service.SensorService;
import com.moral.webSocketServer.BSTestWebsocketServer;
import com.moral.webSocketServer.BSWebsocketServer;
import com.moral.webSocketServer.WebSocketServer;
 
import com.moral.webSocketServer.WebSocketServerNew;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
 
@Configuration
public class WebSocketConfig {
 
    //本地测试需要将注释解开
    /*@Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }*/
 
    @Bean
    public MessageConverter jsonMessageConverter() {
        return new Jackson2JsonMessageConverter();
    }
 
    @Autowired
    public void setMessageService(DeviceService deviceService){
        WebSocketServer.deviceService=deviceService;
        WebSocketServerNew.deviceService=deviceService;
        BSWebsocketServer.deviceService=deviceService;
        BSTestWebsocketServer.deviceService=deviceService;
    }
    @Autowired
    public void setSensorService( SensorService sensorService){
        BSTestWebsocketServer.sensorService=sensorService;
        BSWebsocketServer.sensorService=sensorService;
    }
 
}