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
b5337f3b
Commit
b5337f3b
authored
May 16, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
7c8a7b32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
75 deletions
+3
-75
center-manage/app/config/socket.server.js
+3
-75
No files found.
center-manage/app/config/socket.server.js
View file @
b5337f3b
var
Server
=
require
(
'socket.io'
);
var
system
=
require
(
'../base/system'
);
var
redisClient
=
system
.
getObject
(
"util.redisClient"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
notifyCtl
=
system
.
getObject
(
"web.socketNotifyCtl"
);
const
msgHistoryService
=
system
.
getObject
(
"service.msghistorySve"
);
class
MsgHandler
{
...
...
@@ -16,14 +15,6 @@ class MsgHandler{
redisClient
.
publish
(
ukchannel
,
JSON
.
stringify
(
msg
));
}).
catch
(
e
=>
{
console
.
log
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->notifyClient接口调用异常error:"
,
op
:
"chatmsg"
,
content
:
e
.
stack
,
clientIp
:
null
,
agent
:
""
,
});
});
}
init
(){
...
...
@@ -42,86 +33,23 @@ class MsgHandler{
redisClient
.
publish
(
tochannel
,
JSON
.
stringify
(
msg
));
}).
catch
(
e
=>
{
console
.
log
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->发布消息->持久化消息接口调用异常error:"
,
op
:
"chatmsg"
,
content
:
e
,
clientIp
:
null
,
agent
:
""
,
});
});
//self.server.users[to].emit("chatmsg",msg);
});
this
.
client
.
on
(
"mryzmsg"
,
async
msg
=>
{
try
{
const
from
=
msg
.
from
;
const
to
=
msg
.
to
;
const
msgContent
=
msg
.
content
;
var
fromArrs
=
from
.
split
(
"¥"
);
var
toArrs
=
to
.
split
(
"¥"
);
var
fromId
=
Number
(
fromArrs
[
1
]);
var
toId
=
Number
(
toArrs
[
1
]);
var
fromChannel
=
fromArrs
[
0
]
+
"¥"
+
fromArrs
[
1
];
var
toChannel
=
toArrs
[
0
]
+
"¥"
+
toArrs
[
1
];
// 消息对象
var
msgH
=
{
msgType
:
msg
.
msgType
||
"mryzSingle"
,
sender
:
from
,
senderId
:
fromId
,
target
:
msg
.
to
,
targetId
:
toId
,
content
:
msgContent
,
isRead
:
false
,
businessLicense_id
:
msg
.
businessLicense_id
||
0
,
};
msgH
=
await
msgHistoryService
.
saveMsg
(
msgH
);
redisClient
.
publish
(
fromChannel
,
JSON
.
stringify
(
msgH
));
if
(
fromChannel
!=
toChannel
)
{
redisClient
.
publish
(
toChannel
,
JSON
.
stringify
(
msgH
));
}
}
catch
(
e
)
{
console
.
error
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->发布每日易照消息->持久化每日易照消息接口调用异常error:"
,
op
:
"mryzmsg"
,
content
:
e
,
clientIp
:
null
,
agent
:
""
,
});
}
//self.server.users[to].emit("chatmsg",msg);
});
//响应消息处理
this
.
client
.
on
(
"replymsg"
,(
msg
,
fn
)
=>
{
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
msg
.
cls
);
console
.
log
(
invokeObj
);
var
invokeObj
=
system
.
getObject
(
"web."
+
msg
.
pkgname
+
"."
+
msg
.
cls
);
if
(
invokeObj
[
msg
.
method
]){
p
=
invokeObj
[
msg
.
method
].
apply
(
invokeObj
,[
msg
.
data
]);
}
p
.
then
(
r
=>
{
fn
(
r
);
}).
then
(()
=>
{
logCtl
.
info
({
optitle
:
"socket.server.js->响应消息处理->接口调用info:"
,
op
:
msg
.
cls
+
"/"
+
msg
.
method
,
content
:
JSON
.
stringify
(
msg
.
data
),
clientIp
:
null
,
agent
:
""
,
});
console
.
log
(
"call success"
)
}).
catch
(
err
=>
{
logCtl
.
error
({
optitle
:
"socket.server.js->响应消息处理->接口调用异常error:"
,
op
:
msg
.
cls
+
"/"
+
msg
.
method
,
content
:
JSON
.
stringify
(
msg
.
data
),
clientIp
:
null
,
agent
:
""
,
});
console
.
log
(
err
)
})
});
}
...
...
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