Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] 创建 conversation 时的属性绑定到 data 上面。 #72

Merged
merged 2 commits into from
Apr 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion demo/demo1/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var appId = '9p6hyhh60av3ukkni3i9z53q1l8yy3cijj6sie3cewft18vm';
var clientId = 'LeanCloud111';

// 如果想加入一个已有房间,可以传入 roomId
var roomId = '551a2847e4b04d688d73dc54';
var roomId;
var rt;
var conv;
var convOld;
Expand Down Expand Up @@ -74,10 +74,12 @@ rt.on('close', function() {

// 当 Conversation 被创建时触发,当然您可以使用回调函数来处理,不一定要监听这个事件
rt.on('create', function(data) {

// 当前用户加入这个 Conversation
conv.join(function(data) {
console.log('当前用户成功加入 Conversation');
});

// 向这个 Conversation 添加新的用户
conv.add([
'LeanCloud03', 'LeanCloud04'
Expand Down Expand Up @@ -168,6 +170,10 @@ rt.on('create', function(data) {
console.log('取得当前的用户数量:' + num);
});

if (!roomId) {
roomId = conv.id;
}

// 这是一个已有的对话,通过房间 id 生成它的对话实例
rt.conv(roomId, function(obj) {

Expand All @@ -180,6 +186,7 @@ rt.on('create', function(data) {
], function(data) {
console.log('已有的房间成功添加新的用户:', data);
});
console.log('获取房间的初始化数据', convOld.data);
} else {
console.log('你想获取的房间不存在');
}
Expand Down
2 changes: 2 additions & 0 deletions src/AV.realtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ void function(win) {
// 如果服务器端有这个 id
if (data.length) {
convObject.id = argument;
// 获取初始化时的属性
convObject.data = data[0];
}

if (callback) {
Expand Down