You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
557 B
18 lines
557 B
package com.iflytop.gd.app.service;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.iflytop.gd.infrastructure.config.WebSocketServer;
|
|
import com.iflytop.gd.app.model.dto.WebsocketResult;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class WebSocketService {
|
|
|
|
public void push(String type, Object data) {
|
|
WebsocketResult websocketResult = new WebsocketResult();
|
|
websocketResult.setType(type);
|
|
websocketResult.setData(data);
|
|
WebSocketServer.sendMessageToClients(JSONUtil.toJsonStr(websocketResult));
|
|
}
|
|
|
|
}
|