Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Sim
提交
cbab7af1
S
Sim
项目概览
梦境迷离
/
Sim
10 个月 前同步成功
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Sim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cbab7af1
编写于
5月 30, 2020
作者:
梦境迷离
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix websocket bug
上级
05b5bead
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
16 deletion
+21
-16
src/main/resources/application.properties
src/main/resources/application.properties
+2
-2
src/main/scala/cn/edu/layim/service/CookieService.scala
src/main/scala/cn/edu/layim/service/CookieService.scala
+16
-11
src/main/scala/cn/edu/layim/websocket/WebSocketProvider.scala
...main/scala/cn/edu/layim/websocket/WebSocketProvider.scala
+1
-1
src/main/scala/cn/edu/layim/websocket/WebSocketService.scala
src/main/scala/cn/edu/layim/websocket/WebSocketService.scala
+2
-2
未找到文件。
src/main/resources/application.properties
浏览文件 @
cbab7af1
...
...
@@ -44,6 +44,6 @@ spring.redis.pool.max-active=8
spring.redis.pool.max-wait
=
-1
spring.redis.timeout
=
2000
#Log
logging.level.*=
warn
logging.level.cn.edu.layim.repository
=
warn
logging.level.*=
info
logging.level.cn.edu.layim.repository
=
info
logging.file
=
./log/LayIM.log
\ No newline at end of file
src/main/scala/cn/edu/layim/service/CookieService.scala
浏览文件 @
cbab7af1
...
...
@@ -41,18 +41,23 @@ class CookieService {
userCookie
.
setPath
(
"/"
)
response
.
addCookie
(
userCookie
)
}
else
{
//没有勾选时,清楚cookie
val
cookies
=
request
.
getCookies
;
for
(
cookie
<-
cookies
)
{
val
cookieName
=
Try
(
new
String
(
baseD
.
decode
(
cookie
.
getName
))).
getOrElse
(
""
)
if
(
cookieName
==
user
.
getEmail
)
{
LOGGER
.
info
(
s
"remove cookie for user => [email = ${user.getEmail}, cookie name = $cookieName]"
)
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
try
{
//没有勾选时,清楚cookie
val
cookies
=
request
.
getCookies
for
(
cookie
<-
cookies
)
{
val
cookieName
=
new
String
(
baseD
.
decode
(
cookie
.
getName
))
if
(
cookieName
==
user
.
getEmail
)
{
LOGGER
.
info
(
s
"remove cookie for user => [email = ${user.getEmail}, cookie name = $cookieName]"
)
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
}
}
catch
{
case
e
:
Exception
=>
LOGGER
.
error
(
s
"failed in cookie service: $e"
)
}
}
}
...
...
src/main/scala/cn/edu/layim/websocket/WebSocketProvider.scala
浏览文件 @
cbab7af1
...
...
@@ -48,7 +48,7 @@ class WebSocketProvider @Autowired() (redisService: RedisService) {
private
lazy
val
jobActor
=
system
.
actorOf
(
Props
(
classOf
[
ScheduleJobActor
]))
//重连是3秒
system
.
scheduler
.
schedule
(
5000
milliseconds
,
6
0000
milliseconds
,
jobActor
,
OnlineUserMessage
)
system
.
scheduler
.
schedule
(
5000
milliseconds
,
1
0000
milliseconds
,
jobActor
,
OnlineUserMessage
)
/**
* 处理连接与消息处理
...
...
src/main/scala/cn/edu/layim/websocket/WebSocketService.scala
浏览文件 @
cbab7af1
...
...
@@ -32,7 +32,7 @@ object WebSocketService {
private
final
lazy
val
LOGGER
:
Logger
=
LoggerFactory
.
getLogger
(
WebSocketService
.
getClass
)
private
final
lazy
val
application
=
Application
.
getApplicationContext
final
lazy
val
actorRefSessions
=
new
ConcurrentHashMap
[
Integer
,
ActorRef
]
final
val
actorRefSessions
=
new
ConcurrentHashMap
[
Integer
,
ActorRef
]
private
lazy
val
userService
:
UserService
=
application
.
getBean
(
classOf
[
UserService
])
private
lazy
val
redisService
:
RedisService
=
application
.
getBean
(
classOf
[
RedisService
])
...
...
@@ -262,6 +262,6 @@ object WebSocketService {
//用于统计实时在线的人数,根据ConcurrentHashMap特性,该人数不会很准确
//重连之后会重新加入进来,但与Redis还是有差异
def
getConnections
=
actorRefSessions
.
size
()
@volatile
def
getConnections
=
actorRefSessions
.
size
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录