Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
a5285489
Commit
a5285489
authored
Sep 29, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
16ce9220
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
im-center/app/config/socket.server2.js
+16
-8
No files found.
im-center/app/config/socket.server2.js
View file @
a5285489
...
...
@@ -46,8 +46,10 @@ class RoomSet {
await
redisClient
.
sadd
(
this
.
roomsetkey
,
roomname
)
//房间中缓存链接的客户uk
await
redisClient
.
sadd
(
roomname
,
ukencstr
)
// 订阅房间消息
// 订阅房间消息
,进入一个房间就要订阅这个房间的消息
await
redisClient
.
subscribe
(
roomname
,
this
.
server
);
//发送新登录用户的广播
redisClient
.
publish
(
"brc"
,
"hello,world,i coming...."
)
return
{}
}
...
...
@@ -104,7 +106,7 @@ class MsgHandler {
});
//self.server.users[to].emit("chatmsg",msg);
});
//http-proxy转发处理
//响应消息处理
this
.
client
.
on
(
"replymsg"
,
(
msg
,
fn
)
=>
{
var
p
=
null
;
...
...
@@ -179,7 +181,7 @@ class SocketServer {
console
.
log
(
"rm ano..."
,
prevukstr
)
delete
self
.
users
[
prevukstr
]
delete
self
.
uinfos
[
prevukstr
]
this
.
rooms
.
exitRoom
(
prevukstr
,
prevukstr
)
self
.
rooms
.
exitRoom
(
prevukstr
,
prevukstr
)
}
self
.
socketidMap
[
client
.
id
]
=
ukencstr
//保存所有的客户端的消息处理器
...
...
@@ -187,7 +189,7 @@ class SocketServer {
self
.
uinfos
[
ukencstr
]
=
encuk
//(订阅uk)开私人频道房间,并缓存房间名
this
.
rooms
.
joinRoom
(
ukencstr
,
ukencstr
)
self
.
rooms
.
joinRoom
(
ukencstr
,
ukencstr
)
})
// //
...
...
@@ -198,10 +200,16 @@ class SocketServer {
client
.
on
(
'disconnect'
,
async
function
(
r
)
{
console
.
log
(
"connection.........................................dismiss............."
,
client
.
id
,
r
);
let
ukencstr
=
self
.
socketidMap
[
client
.
id
]
delete
self
.
users
[
ukencstr
]
delete
self
.
uinfos
[
ukencstr
]
delete
self
.
socketidMap
[
client
.
id
]
this
.
rooms
.
exitRoom
(
ukencstr
,
ukencstr
)
if
(
ukencstr
&&
ukencstr
!=
"undefined"
)
{
console
.
log
(
ukencstr
,
"will delete....."
)
delete
self
.
users
[
ukencstr
]
delete
self
.
uinfos
[
ukencstr
]
//断开链接时,从自己私人房间退出
self
.
rooms
.
exitRoom
(
ukencstr
,
ukencstr
)
//删除私人房间uk
delete
self
.
socketidMap
[
client
.
id
]
}
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment