Showing
1 changed file
with
42 additions
and
0 deletions
public/js/service/socket/receive.js
0 → 100644
1 | +/** | ||
2 | + * 消息发送 | ||
3 | + * @author <qi.li@yoho.cn> | ||
4 | + * @date 2017/03/13 | ||
5 | + */ | ||
6 | +var uuid = require('uuid'); | ||
7 | +var chat = require('./chat'); | ||
8 | +var sockConf = require('./config'); | ||
9 | +var recTypes = sockConf.recType; | ||
10 | +var conMSG = sockConf.conversationMessage; | ||
11 | + | ||
12 | +/** | ||
13 | + * 发送 | ||
14 | + * @param {msg} 消息体 | ||
15 | + */ | ||
16 | +function _send(msg) { | ||
17 | + chat.send(msg); | ||
18 | +} | ||
19 | + | ||
20 | +/** | ||
21 | + * 图片发送 | ||
22 | + */ | ||
23 | +exports.image = function(path) { | ||
24 | + var IMG_TYPE = 2; // 图片消息 | ||
25 | + conMSG.type = recTypes.CU_SEND; | ||
26 | + conMSG.chatMessage.content = path; | ||
27 | + conMSG.chatMessage.type = IMG_TYPE; | ||
28 | + conMSG.uuid = uuid.v4(); | ||
29 | + _send(conMSG); | ||
30 | +}; | ||
31 | + | ||
32 | +/** | ||
33 | + * 文本发送 | ||
34 | + */ | ||
35 | +exports.text = function(path) { | ||
36 | + // var IMG_TYPE = 2; // 文本消息 | ||
37 | + // conMSG.type = recTypes.CU_SEND; | ||
38 | + // conMSG.chatMessage.content = path; | ||
39 | + // conMSG.chatMessage.type = IMG_TYPE; | ||
40 | + // conMSG.uuid = uuid.v4(); | ||
41 | + // _send(conMSG); | ||
42 | +}; |
-
Please register or login to post a comment