[lib.room-controller] fix sending { rid: }
This commit is contained in:
parent
2f5894c459
commit
bcf4dafcc5
|
@ -27,7 +27,7 @@ export default class ChannelController{
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
nav(channel_id=null){
|
nav(channel_id=null){
|
||||||
|
|
||||||
console.log(`channel.nav(${channel_id})`);
|
// console.log(`channel.nav(${channel_id})`);
|
||||||
|
|
||||||
/* (1) Get channel data */
|
/* (1) Get channel data */
|
||||||
var channel = this.get(channel_id);
|
var channel = this.get(channel_id);
|
||||||
|
@ -48,7 +48,7 @@ export default class ChannelController{
|
||||||
gs.get.room.fetch();
|
gs.get.room.fetch();
|
||||||
|
|
||||||
/* (6) Open channel websocket */
|
/* (6) Open channel websocket */
|
||||||
( window.csock != null ) && csock.close();
|
( window.csock != null ) && csock.close();
|
||||||
window.csock = new wscd(`wss://ws.douscord.xdrm.io/channel/${channel.id}`, { token: auth.token });
|
window.csock = new wscd(`wss://ws.douscord.xdrm.io/channel/${channel.id}`, { token: auth.token });
|
||||||
csock.onreceive = (_dat) => {
|
csock.onreceive = (_dat) => {
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ export default class ChannelController{
|
||||||
csock.bind();
|
csock.bind();
|
||||||
|
|
||||||
/* (6) Log channel */
|
/* (6) Log channel */
|
||||||
console.log(`[channel.current] ${channel.link} (${channel.label})`);
|
// console.log(`[channel.current] ${channel.link} (${channel.label})`);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ export default class ChannelController{
|
||||||
*
|
*
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
dump(channels){
|
dump(channels){
|
||||||
console.log(`channel.dump([${channels instanceof Array?channels.length:0}])`);
|
// console.log(`channel.dump([${channels instanceof Array?channels.length:0}])`);
|
||||||
|
|
||||||
/* (1) Check @channels type */
|
/* (1) Check @channels type */
|
||||||
if( !(channels instanceof Array) )
|
if( !(channels instanceof Array) )
|
||||||
|
@ -197,7 +197,7 @@ export default class ChannelController{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (4) Emulate navigatation from URL */
|
/* (4) Emulate navigatation from URL */
|
||||||
console.log(`[restore.channel] ${redirect_id}`);
|
// console.log(`[restore.channel] ${redirect_id}`);
|
||||||
this.nav(redirect_id);
|
this.nav(redirect_id);
|
||||||
|
|
||||||
}.bind(this), auth.token);
|
}.bind(this), auth.token);
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default class RoomController{
|
||||||
*
|
*
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
nav(type=null, id=null){
|
nav(type=null, id=null){
|
||||||
console.log(`room.nav(${type}, ${id})`);
|
// console.log(`room.nav(${type}, ${id})`);
|
||||||
|
|
||||||
/* (1) Try to get current room from id */
|
/* (1) Try to get current room from id */
|
||||||
let room = this.get(type, id);
|
let room = this.get(type, id);
|
||||||
|
@ -38,21 +38,21 @@ export default class RoomController{
|
||||||
if( Object.keys(room).length == 0 )
|
if( Object.keys(room).length == 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* (3) Close last room */
|
/* (3) Update @active room */
|
||||||
|
|
||||||
/* (4) Open new room */
|
|
||||||
|
|
||||||
/* (5) Update @active room */
|
|
||||||
this[type].current = room.id;
|
this[type].current = room.id;
|
||||||
|
|
||||||
/* (6) Update buffer */
|
/* (4) Open new room */
|
||||||
|
if( type === 'text' && csock instanceof wscd )
|
||||||
|
csock.send({ buffer: { rid: room.id } });
|
||||||
|
|
||||||
|
/* (5) Update buffer */
|
||||||
this._buffer[type] = {};
|
this._buffer[type] = {};
|
||||||
for( let r of this[type].list )
|
for( let r of this[type].list )
|
||||||
if( r.id === this[type].current )
|
if( r.id === this[type].current )
|
||||||
this._buffer[type] = r;
|
this._buffer[type] = r;
|
||||||
|
|
||||||
|
|
||||||
console.log(`[room.${type}.opened] ${room.name} (${room.id})`, room.id);
|
// console.log(`[room.${type}.opened] ${room.name} (${room.id})`, room.id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ export default class RoomController{
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
dump(rooms, append=false){
|
dump(rooms, append=false){
|
||||||
|
|
||||||
console.log(`room.dump([${rooms instanceof Array?rooms.length:-1}])`);
|
// console.log(`room.dump([${rooms instanceof Array?rooms.length:-1}])`);
|
||||||
|
|
||||||
/* (1) Check @rooms type */
|
/* (1) Check @rooms type */
|
||||||
if( !(rooms instanceof Array) )
|
if( !(rooms instanceof Array) )
|
||||||
|
@ -149,7 +149,7 @@ export default class RoomController{
|
||||||
*
|
*
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
get(type=null, id=null){
|
get(type=null, id=null){
|
||||||
console.log(`room.get(${type}, ${id})`);
|
// console.log(`room.get(${type}, ${id})`);
|
||||||
|
|
||||||
/* (1) Manage invalid @type */
|
/* (1) Manage invalid @type */
|
||||||
if( typeof type !== 'string' || this[type] == null )
|
if( typeof type !== 'string' || this[type] == null )
|
||||||
|
@ -208,7 +208,6 @@ export default class RoomController{
|
||||||
/* (3) Store channel users */
|
/* (3) Store channel users */
|
||||||
gs.get.content.cbuf.users = rs.channel.users;
|
gs.get.content.cbuf.users = rs.channel.users;
|
||||||
|
|
||||||
|
|
||||||
}.bind(this), auth.token);
|
}.bind(this), auth.token);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue