|
@@ -37,15 +37,26 @@ class LookuserService extends CrudService {
|
|
|
lookuser.switchrole = switchrole;
|
|
|
const res = await lookuser.save();
|
|
|
if (res) {
|
|
|
- const { mq } = this.ctx;
|
|
|
- if (mq) {
|
|
|
- const exchange = 'switch_role_' + res.userid;
|
|
|
- const parm = {
|
|
|
- durable: true,
|
|
|
+ if (switchrole === 'anchor') {
|
|
|
+ const { mq } = this.ctx;
|
|
|
+ if (mq) {
|
|
|
+ const exchange = 'switch_role_' + res.userid;
|
|
|
+ const parm = {
|
|
|
+ durable: true,
|
|
|
+ headers: {
|
|
|
+ userid: res.userid,
|
|
|
+ } };
|
|
|
+ await mq.fanout(exchange, res.userid, JSON.stringify(res), parm);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const url = `http://127.0.0.1:6666/api/stomp/exitroom?uid=${res.userid}&roomid=${res.roomname}`;
|
|
|
+ await this.ctx.curl(url, {
|
|
|
+ method: 'get',
|
|
|
headers: {
|
|
|
- userid: res.userid,
|
|
|
- } };
|
|
|
- await mq.fanout(exchange, res.userid, JSON.stringify(res), parm);
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ },
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
return res;
|