好友
阅读权限10
听众
最后登录1970-1-1
|
@Component
@ServerEndpoint(value = "/chat")
public class ChatEndpoint {
@Autowired
private AuctionMapper auctionMapper;
private static Set<Session> clients = Collections.synchronizedSet(new HashSet<>());
@OnOpen
public void onOpen(Session session) {
clients.add(session);
}
@OnClose
public void onClose(Session session) {
clients.remove(session);
}
@OnMessage
public void onMessage(String message, Session session) throws IOException, SQLException {
System.out.println("我是mess"+message);
JSONObject json = new JSONObject(message);
String text = json.getString("text");
String senderId = String.valueOf(json.getInt("senderId"));
String receiverId = String.valueOf(json.getInt("receiverId"));
Message mg = new Message();
mg.setSenderId(senderId);
mg.setReceiverId(receiverId);
mg.setJsonMsg(text);
auctionMapper.InIoMessage(mg);注入为null运行不了SQL语句 |
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|