|
@@ -118,7 +118,8 @@ export class MessageService {
|
|
|
// };
|
|
|
this.joinReady();
|
|
|
await this.loginRTM();
|
|
|
- this.subscribeMessage(channelName);
|
|
|
+ // this.subscribeMessage(channelName);
|
|
|
+ this.publishMessage('user-online',channelName,'USER')//用户上线通知
|
|
|
}
|
|
|
/* 监听频道消息 */
|
|
|
joinReady(channelName?: string) {
|
|
@@ -160,7 +161,7 @@ export class MessageService {
|
|
|
});
|
|
|
this.options.connectState = true; // 登录成功
|
|
|
let userMateData = await this.getUserMetadata(this.userId);
|
|
|
- if(!userMateData){
|
|
|
+ if (!userMateData) {
|
|
|
let user = Parse.User.current();
|
|
|
const metadata = [
|
|
|
{
|
|
@@ -192,7 +193,7 @@ export class MessageService {
|
|
|
logOutRTM() {
|
|
|
this.rtmClient.logout().then(() => {
|
|
|
console.log('logout success');
|
|
|
- this.options.connectState = false
|
|
|
+ this.options.connectState = false;
|
|
|
});
|
|
|
}
|
|
|
/* 订阅消息 */
|
|
@@ -267,7 +268,7 @@ export class MessageService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async publishMessage(message: string, channelName: string) {
|
|
|
+ async publishMessage(message: string, channelName: string, channelType?:string) {
|
|
|
const payload = { type: 'text', message: message };
|
|
|
const publishMessage = JSON.stringify(payload);
|
|
|
const publishOptions = { channelType: 'MESSAGE' };
|