2012112816134667.jpg (23.25 KB, 下载次数: 1085)
下载附件 保存到相册
7 年前 上传
1.png (20.2 KB, 下载次数: 1091)
2.png (38.8 KB, 下载次数: 1158)
pomelo init chatofpomelo
3.png (5.65 KB, 下载次数: 1134)
4.png (40.76 KB, 下载次数: 1045)
5.png (7.74 KB, 下载次数: 1197)
pomelo.request('connector.entryHandler.enter', {username: username}, function(){ });
handler.enter = function(msg, session, next) { session.bind(uid); session.on('closed', onUserLeave.bind(null, this.app)); };
app.rpc.chat.chatRemote.add(session, uid, app.get('serverId'), function(data){});
remote.add = function(uid, sid, cb){ var channel = channelService.getChannel('pomelo', true); if(!!channel) channel.add(uid, sid); };
pomelo.request('chat.chatHandler.send', {content: msg, from: username, target: target}, function(){});
handler.send = function(msg, session, next) { var param = {route: 'onChat', msg: msg.content, from: msg.from, target: msg.target}; // send messages };
var channel = channelService.getChannel('pomelo', false); channel.pushMessage(param);
pomelo.on('onChat', function() { addMessage(data.from, data.target, data.msg); $("#chatHistory").show(); };
app.rpc.chat.chatRemote.kick(session, session.uid, app.get('serverId'), 'pomelo', null);
handler.kick = function(uid, sid, name){ var channel = channelService.getChannel(name, false); if (!!channel) { channel.leave(uid,sid); } };
{ "development":{ "connector":[ { "id":"connector-server-1", "host":"127.0.0.1", "clientPort":3050, "frontend": true } ], "chat":[ { "id":"chat-server-1", "host":"127.0.0.1", "port":6050 } ] }, "production":{ "connector":[ { "id":"connector-server-1", "host":"127.0.0.1", "clientPort":3050, "frontend": true } ], "chat":[ { "id":"chat-server-1", "host":"127.0.0.1", "port":6050 } ] } }
pomelo start
6.png (28.97 KB, 下载次数: 1173)
{ "development":{ "gate":[ { "id":"gate-server-1", "host":"127.0.0.1", "clientPort":3014, "frontend": true } ], "connector":[ { "id":"connector-server-1", "host":"127.0.0.1", "clientPort":3050, "frontend": true }, { "id":"connector-server-2", "host":"127.0.0.1", "clientPort":3051, "frontend": true }, { "id":"connector-server-3", "host":"127.0.0.1", "clientPort":3052, "frontend": true } ], "chat":[ { "id":"chat-server-1", "host":"127.0.0.1", "port":6050 }, { "id":"chat-server-2", "host":"127.0.0.1", "port":6051 }, { "id":"chat-server-3", "host":"127.0.0.1", "port":6052 } ] }, "production":{ "gate":[ { "id":"gate-server-1", "host":"127.0.0.1", "clientPort":3014, "frontend": true } ], "connector":[ { "id":"connector-server-1", "host":"127.0.0.1", "clientPort":3050, "frontend": true }, { "id":"connector-server-2", "host":"127.0.0.1", "clientPort":3051, "frontend": true }, { "id":"connector-server-3", "host":"127.0.0.1", "clientPort":3052, "frontend": true } ], "chat":[ { "id":"chat-server-1", "host":"127.0.0.1", "port":6050 }, { "id":"chat-server-2", "host":"127.0.0.1", "port":6051 }, { "id":"chat-server-3", "host":"127.0.0.1", "port":6052 } ] } }
7.png (38.8 KB, 下载次数: 1160)
//routeUtil.js exp.chat = function(session, msg, app, cb) { var chatServers = app.getServersByType('chat'); if (!chatServers) { cb(new Error('can not find chat servers.')); return; } var res = dispatcher.dispatch(session.get('rid'), chatServers); cb(null, res.id); }; //app.js app.configure('production|development', function() { app.route('chat', routeUtil.chat); });
// app configuration app.configure('production|development', 'connector', function(){ app.set('connectorConfig', { connector : pomelo.connectors.hybridconnector, heartbeat : 3, useDict : true, useProtobuf : true }); }); app.configure('production|development', 'gate', function(){ app.set('connectorConfig', { connector : pomelo.connectors.hybridconnector, }); });
来源:即时通讯网 - 即时通讯开发者社区!
轻量级开源移动端即时通讯框架。
快速入门 / 性能 / 指南 / 提问
轻量级Web端即时通讯框架。
详细介绍 / 精编源码 / 手册教程
移动端实时音视频框架。
详细介绍 / 性能测试 / 安装体验
基于MobileIMSDK的移动IM系统。
详细介绍 / 产品截图 / 安装体验
一套产品级Web端IM系统。
详细介绍 / 产品截图 / 演示视频
引用此评论
精华主题数超过100个。
连续任职达2年以上的合格正式版主
为论区做出突出贡献的开发者、版主等。
Copyright © 2014-2024 即时通讯网 - 即时通讯开发者社区 / 版本 V4.4
苏州网际时代信息科技有限公司 (苏ICP备16005070号-1)
Processed in 0.131841 second(s), 39 queries , Gzip On.