Skip to content

Commit

Permalink
🔧 停用过期的websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Dec 26, 2024
1 parent d7ff149 commit 5c0fb05
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public class ChatroomChannel implements WebSocketChannel {
*/
@Override
public void onConnect(final WebSocketSession session) {
// 发送过期客户端消息
String text = "{\"userOId\":1630399192600,\"userAvatarURL\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"userNickname\":\"阿达\",\"oId\":\"" + System.currentTimeMillis() + "\",\"userName\":\"adlered\",\"type\":\"msg\",\"content\":\"<p><\\/p><h3>您正在使用过期的客户端<\\/h3>\\n<p>您的客户端正在使用过期的协议连接到摸鱼派聊天室,该协议已被停用,无法接收消息。<\\/p>\\n<p>请将客户端更新到最新版本以享受更快的聊天室服务,如已是最新版本,请联系客户端开发者更新客户端。<\\/p>\\n<p>新版摸鱼派聊天室协议开发指南:<a href=\\\"https://fishpi.cn/article/1733591297543\\\" target=\\\"_blank\\\" rel=\\\"nofollow\\\">https://fishpi.cn/article/1733591297543<\\/a><\\/p>\\n<p><\\/p>\",\"md\":\"### 您正在使用过期的客户端\\n\\n您的客户端正在使用过期的协议连接到摸鱼派聊天室,该协议已被停用,无法接收消息。\\n\\n请将客户端更新到最新版本以享受更快的聊天室服务,如已是最新版本,请联系客户端开发者更新客户端。\\n\\n新版摸鱼派聊天室协议开发指南:https://fishpi.cn/article/1733591297543\",\"userAvatarURL20\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"sysMetal\":\"{\\\"list\\\":[{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派铁粉\\\",\\\"description\\\":\\\"捐助摸鱼派达1024RMB; 编号No.9\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht3-b97ea102.jpg&backcolor=ee3a8c&fontcolor=ffffff\\\",\\\"enabled\\\":true},{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派忠粉\\\",\\\"description\\\":\\\"捐助摸鱼派达256RMB; 编号No.20\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht2-bea67b29.jpg&backcolor=87cefa&fontcolor=efffff\\\",\\\"enabled\\\":true},{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派粉丝\\\",\\\"description\\\":\\\"捐助摸鱼派达16RMB; 编号No.38\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht1-d8149de4.jpg&backcolor=ffffff&fontcolor=ff3030\\\",\\\"enabled\\\":true}]}\",\"client\":\"Web/PC网页端\",\"time\":\"" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()) + "\",\"userAvatarURL210\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"userAvatarURL48\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\"}";
sendText(session, text);
session.close();
/**
String userStr = session.getHttpSession().getAttribute(User.USER);
try {
userStr = ApiProcessor.getUserByKey(session.getParameter("apiKey")).toString();
Expand Down Expand Up @@ -114,12 +119,10 @@ public void onConnect(final WebSocketSession session) {
AdminProcessor.manager.onMessageSent(4, msgStr.length());
// 保存 Active 信息
userActive.put(user.optString("userName"), System.currentTimeMillis());
// 发送过期客户端消息
String text = "{\"userOId\":1630399192600,\"userAvatarURL\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"userNickname\":\"阿达\",\"oId\":\"" + System.currentTimeMillis() + "\",\"userName\":\"adlered\",\"type\":\"msg\",\"content\":\"<p><\\/p><h3>您正在使用过期的客户端<\\/h3>\\n<p>您的客户端正在使用过期的协议连接到摸鱼派聊天室,该协议将于 2025 年 3 月 1 日 被停用。<\\/p>\\n<p>请将客户端更新到最新版本以享受更快的聊天室服务,如已是最新版本,请联系客户端开发者更新客户端。<\\/p>\\n<p>新版摸鱼派聊天室协议开发指南:<a href=\\\"https://fishpi.cn/article/1733591297543\\\" target=\\\"_blank\\\" rel=\\\"nofollow\\\">https://fishpi.cn/article/1733591297543<\\/a><\\/p>\\n<p><\\/p>\",\"md\":\"### 您正在使用过期的客户端\\n\\n您的客户端正在使用过期的协议连接到摸鱼派聊天室,该协议将于 2025年3月1日 被停用。\\n\\n请将客户端更新到最新版本以享受更快的聊天室服务,如已是最新版本,请联系客户端开发者更新客户端。\\n\\n新版摸鱼派聊天室协议开发指南:https://fishpi.cn/article/1733591297543\",\"userAvatarURL20\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"sysMetal\":\"{\\\"list\\\":[{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派铁粉\\\",\\\"description\\\":\\\"捐助摸鱼派达1024RMB; 编号No.9\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht3-b97ea102.jpg&backcolor=ee3a8c&fontcolor=ffffff\\\",\\\"enabled\\\":true},{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派忠粉\\\",\\\"description\\\":\\\"捐助摸鱼派达256RMB; 编号No.20\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht2-bea67b29.jpg&backcolor=87cefa&fontcolor=efffff\\\",\\\"enabled\\\":true},{\\\"data\\\":\\\"\\\",\\\"name\\\":\\\"摸鱼派粉丝\\\",\\\"description\\\":\\\"捐助摸鱼派达16RMB; 编号No.38\\\",\\\"attr\\\":\\\"url=https://file.fishpi.cn/2021/12/ht1-d8149de4.jpg&backcolor=ffffff&fontcolor=ff3030\\\",\\\"enabled\\\":true}]}\",\"client\":\"Web/PC网页端\",\"time\":\"" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()) + "\",\"userAvatarURL210\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\",\"userAvatarURL48\":\"https://file.fishpi.cn/2023/12/blob-1d3b18ec.png\"}";
sendText(session, text);
} else {
session.close();
}
**/
}

private static SimpleCurrentLimiter customMessageCurrentLimit = new SimpleCurrentLimiter(60, 6);
Expand Down

0 comments on commit 5c0fb05

Please sign in to comment.