room.setCustomProperties 传参有什么额外的要求吗?
为什么我传{a:1}是可以的,但是传{a:{b:1}}就报错?(4313 - INVALID_ROOM_ATTR)
btw: 为什么工单系统我没法用?有什么要求吗?我是付费用户,付费金额>100
-
创建时间
19年8月13日
-
最后回复
19年8月15日
- 11
回复
- 331
浏览
- 2
用户
- 1
赞
- 3
链接
room.setCustomProperties 传参有什么额外的要求吗?
为什么我传{a:1}是可以的,但是传{a:{b:1}}就报错?(4313 - INVALID_ROOM_ATTR)
btw: 为什么工单系统我没法用?有什么要求吗?我是付费用户,付费金额>100
我用的是js ,
https://leancloud.github.io/Play-SDK-JS/doc/ 看的是这个文档,
版本是v0.18.0-beta
用法可以参考 单元测试
如果还有问题,请粘贴一下代码和日志。
可以的,我刚刚测试了一下你描述的嵌套对象。
it('test change room properties', () =>
new Promise(async resolve => {
const roomName = 'tcp0_r';
const p0 = newPlay('tcp0_0');
const p1 = newPlay('tcp0_1');
let f0 = false;
let f1 = false;
await p0.connect();
await p0.createRoom({ roomName });
p0.on(Event.ROOM_CUSTOM_PROPERTIES_CHANGED, async () => {
const props = p0.room.customProperties;
expect(props.title).to.be.equal('room311');
expect(props.gold).to.be.equal(1000);
expect(props.data.num).to.be.equal(123);
expect(props.data.detail).to.be.equal('hello');
f0 = true;
if (f0 && f1) {
await p0.close();
await p1.close();
resolve();
}
});
await p1.connect();
await p1.joinRoom(roomName);
p1.on(Event.ROOM_CUSTOM_PROPERTIES_CHANGED, async () => {
const props = p1.room.customProperties;
expect(props.title).to.be.equal('room311');
expect(props.gold).to.be.equal(1000);
expect(props.data.num).to.be.equal(123);
expect(props.data.detail).to.be.equal('hello');
f1 = true;
if (f0 && f1) {
await p0.close();
await p1.close();
resolve();
}
});
const props = {
title: 'room311',
gold: 1000,
data: {
num: 123,
detail: 'hello',
},
};
await p1.room.setCustomProperties(props);
debug(`current room title: ${props.title}`);
expect(props.title).to.be.equal('room311');
debug(`current room gold: ${props.gold}`);
expect(props.gold).to.be.equal(1000);
debug(`current room num: ${props.data.num}`);
expect(props.data.num).to.be.equal(123);
debug(`current room detail: ${props.data.detail}`);
expect(props.data.detail).to.be.equal('hello');
}));
后面也有 Player CustomProperties 的单元测试,就是嵌套的。
Room Properties 和 Player Properties 数据结构是一样的。
3 层嵌套也是没问题的。
日志打开方法