pomelo Channel
来源:互联网 发布:北京大学大数据学院 编辑:程序博客网 时间:2024/04/28 20:25
Api
ChannelService
ChannelService is created by channel component which is a default loaded component of pomelo and channel service would be accessed by app.get(‘channelService’).
createChannel(name) getChannel(name,create) create = true destroyChannel(name) pushMessageByUids(route, msg, uids, opts, cb) broadcast(stype, route, msg, opts, cb)
Channel
add(uid, sid) //uid - user id //sid - frontend server id which user has connected toleave(uid, sid)getMembers()getMember(uid)destroy()pushMessage(route, msg, opts, cb)
Sample
Mainly Used
- getChannel(name,create)
- add(uid, sid)
- pushMessage(route, msg, opts, cb)
- leave(uid,sid)
var exp = module.exports; //get channel var getChannel = exp.getChannel = function() { if(channel) { return channel; } channel = pomelo.app.get('channelService').getChannel('area_' + id, true); return channel; }; //pushMessage getChannel().pushMessage({route: 'onPickItem', entityId: args.entityId, target: args.target, score: treasure.score});/** * Add entity to area * @param {Object} e Entity to add to the area. */ exp.addEntity = function(e) { //e is a entity,it maybe a player if (e.type === EntityType.PLAYER) { getChannel().add(e.id, e.serverId); addEvent(e); //add event listener players[e.id] = e.entityId; } return true; };
0 0
- pomelo Channel
- pomelo的push机制(channel)和源码解读
- pomelo
- Channel
- channel
- channel
- Channel
- channel
- Channel
- Channel
- pomelo介绍
- pomelo初探
- pomelo入门
- 安装pomelo
- pomelo+mongodb
- pomelo 协议
- Pomelo 扩容
- Pomelo 学习
- Fixing Ubuntu Error: Failed to load libGL.so
- Android消息处理机制(Handler、Looper、MessageQueue与Message)
- Android Action总结
- PDF怎么转换成word
- 第三周 课后实践:项目五——数组作数据成员(1)
- pomelo Channel
- 算法竞赛入门经典训练指南——例18 max(a[i]-a[j])且(i<j)
- wcf的简单服务建立
- 玩转百度即用API(2)——身份证查询
- Sql Server 删除所有表
- 第四周 项目一-三角形类的构造函数(四)
- 为chromium增加底部工具栏
- Java实现uint8_t/uint16_t/uint32_t
- 【Node.js基础篇】(四)Node.js实现文件路由功能