sysManage

sysManage

sysManage.sendRosterMessage(msg) ⇒ number

SendSingle chat message

Kind: static method of sysManage
Returns: number - Message ID generated by client

Param Type Description
msg object Message body
msg.uid string Receiver ID
msg.content string Message content
msg.type string Message types: text, image, audio, video, file, location, command, forward
msg.ext string | object Extension field
msg.attachment string | object Attachment info

Example

const message = {
  uid: this.getSid,
  content: '',
  type: 'location',
  attachment: {
    lat: 40.024422,
    lon: 116.398376,
    addr: '奥林匹克森林公园'
  }
};
this.im.sysManage.sendRosterMessage(message);
if (/^\s*$/.test(this.message)) {
  this.message = '';
  return;
}

// 如果需要自定义消息,直接使用 ext 字段即可
this.im.sysManage.sendRosterMessage({
  content: this.message,
  uid: this.getSid
  // ext: "自定义消息字段",
});
setTimeout(() => {
  this.message = '';
}, 200);
const fileInfo = {
  dName: file.name,
  fLen: file.size,
  width: 0,
  height: 0
};
fileInfo.url = res.url;
this.im.sysManage.sendRosterMessage({
  type: this.fileType,
  uid: this.getSid,
  content: '',
  attachment: fileInfo
});
this.$refs.fileRef.value = '';
const message = {
  uid: this.getSid,
  content: '',
  type: 'location',
  attachment: {
    lat: 40.024422,
    lon: 116.398376,
    addr: '奥林匹克森林公园'
  }
};
this.im.sysManage.sendRosterMessage(message);
if (/^\s*$/.test(this.message)) {
  this.message = this.placeholder;
  if (/^\s*$/.test(this.message)) return;
}

// 如果需要自定义消息,直接使用 ext 字段即可
this.im.sysManage.sendRosterMessage({
  content: this.message,
  uid: this.getSid
  // ext: "自定义消息字段",
});
setTimeout(() => {
  this.message = '';
}, 200);
const fileInfo = {
  dName: file.name,
  fLen: file.size,
  width: 0,
  height: 0
};
fileInfo.url = res.url;
this.im.sysManage.sendRosterMessage({
  type: this.fileType,
  uid: this.getSid,
  content: '',
  attachment: fileInfo
});
this.$refs.fileRef.value = '';

sysManage.sendGroupMessage(msg) ⇒ number

SendGroup chat message

Kind: static method of sysManage
Returns: number - Message ID generated by client

Param Type Description
msg object Send message body
msg.gid string GroupID
msg.content string Message content
msg.type string Message types: text, image, audio, video, file, location, command, forward
msg.ext string | object Extension field
msg.attachment string | object Attachment info
msg.priority number Set message diffusion priority, default 0. 0 means diffusion, and the smaller the number, the more diffused.

Example

const message = {
  gid: this.getSid,
  content: '',
  type: 'location',
  attachment: {
    lat: 40.024422,
    lon: 116.398376,
    addr: '奥林匹克森林公园'
  }
};
this.im.sysManage.sendGroupMessage(message);
if (!txt) return;

// 如果需要自定义消息,直接使用 ext 字段即可
this.im.sysManage.sendGroupMessage({
  // type: 'text', // image , file, 默认 text, 可省略
  content: txt,
  gid: this.getSid,
  // ext: "自定义消息字段",
  priority: 0
});
const fileInfo = {
  dName: file.name,
  fLen: file.size,
  width: 0,
  height: 0
};
fileInfo.url = res.url;
this.im.sysManage.sendGroupMessage({
  type: this.fileType,
  gid: this.getSid,
  content: '',
  attachment: fileInfo,
  ext: '自定义消息字段',
  priority: 0
});
this.$refs.fileRef.value = '';

sysManage.requireHistoryMessage(uid, sid, amount)

Request history

Kind: static method of sysManage

Param Type Description
uid number SessionID
sid number Message ID: the message to pull forward from, 0 means pulling from the latest message.
amount number Number of messages to pull

Example

const { rootState, state } = context;
const mid = this.queryHistoryMessageId || 0; // Query historys older than the message with id:mid, 0 means from the last message;
const amount = 20; // Batch size of one time history message query.
rootState.im.sysManage.requireHistoryMessage(state.sid, mid, amount);

context.commit('recordHistoryQuery');

sysManage.sendMentionMessage(params) ⇒ number

Group-sent @message

Kind: static method of sysManage
Returns: number - Message ID generated by client

Param Type Description
params object
params.gid number GroupID
params.txt string Message text content
params.mentionAll boolean Whether to @ everyone
params.mentionList Array.<number> List of @member IDs
params.mentionedMessage string Display content of @messages
params.mentionedMessage string Push content of @messages
params.senderNickname string Sender's nickname

Example

//mention消息
/**
 static const std::string kMentionAll = “mentionAll”;              // bool
 static const std::string kMentionList = “mentionList”;            // vector<int64_t>
 static const std::string kMentionedMessage = “mentionedMessage”;  // string
 static const std::string kPushMessage = “pushMessage”;            // string
 static const std::string kSenderNickname = “senderNickname”;      // string
 */
const mentionAll = false;
const mentionList = this.mentionSelectedUids.map((x) => x - 0);
const mentionedMessage = '';
const pushMessage = '';
const uid = this.im.userManage.getUid();
const rInfo = this.im.rosterManage.getRosterInfo(uid);
const senderNickname = rInfo.username || rInfo.user_id + '';
this.im.sysManage.sendMentionMessage({
  gid: this.getSid,
  // txt: this.willsendMessage,
  txt: this.message,
  mentionAl...

sysManage.sendInputStatusMessage(uid, status) ⇒ number

Send type status

Kind: static method of sysManage
Returns: number - Message ID generated by client

Param Type Description
uid number SessionID
status string Status: nothing - no typing, typing - typing

Example

this.im.sysManage.sendInputStatusMessage(this.getSid, 'typing');
this.im.sysManage.sendInputStatusMessage(this.getSid, 'nothing');
this.im.sysManage.sendInputStatusMessage(this.getSid, 'typing');
this.im.sysManage.sendInputStatusMessage(this.getSid, 'nothing');

sysManage.forwardMessage(param) ⇒ number

Forward message

Kind: static method of sysManage
Returns: number - Message ID generated by client

Param Type Description
param object Parameter
param.uid number Receiver's user ID (set only when forwarding a shingle chat)
param.gid number Receiver's group ID (set only when forwarding a group chat)
param.mid number Message to forwardID

Example

const { rootState, state } = context;
const { type, id: xid } = param; //type: group, roster; id: uid,gid
const fmsg = {};
if (type === 'roster') {
  fmsg.uid = xid;
} else {
  fmsg.gid = xid;
}
fmsg.mid = state.forwardMessage.id;
rootState.im.sysManage.forwardMessage(fmsg);
context.commit('setShowForwardList', false);

sysManage.getMessageStatus(cid, mid, isGroup) ⇒ string

Get message status

Kind: static method of sysManage
Returns: string - Message status: unread, delivered, read

Param Type Default Description
cid number SessionID
mid number MessageID
isGroup boolean false Whether it is a group chat

Example

const fromUid = toNumber(this.message.from);
const toUid = toNumber(this.message.to);
const uid = this.im.userManage.getUid();
const cid = fromUid === uid ? toUid : fromUid;

// status will be unread / delivered / read
return this.im.sysManage.getMessageStatus(cid, this.message.id);
const fromUid = toNumber(this.message.from);
const toUid = toNumber(this.message.to);
const uid = this.im.userManage.getUid();
const cid = fromUid === uid ? toUid : fromUid;

// status will be unread / delivered / read
return this.im.sysManage.getMessageStatus(cid, this.message.id);

sysManage.asyncFileUpload(param) ⇒ Promise.<FileUploadResult>

Upload file

Kind: static method of sysManage
Returns: Promise.<FileUploadResult> - File uploading result

Param Type Description
param object Parameter
param.group_d number GroupID
param.toType number Receiver types: rosterAvatar - user avatar, chat - chat file, groupAvatar - group avatar
param.to_id number Receiver ID
param.file File File
param.fileType string File types: file - general chat file, audio - voice chat file (amr format), image - image chat file, video - video chat file, audio-mp3 - voice chat file (mp3 format), shareFile - general shared file, shareAudio - voice shared file, shareImage - image shared files, shareVideo - video shared files
param.chatType number Chat types: roster - single chat, group - group chat
param.processCallback fileUploadProgress Upload progressCallback

Example

sysManage.getImage(param) ⇒ string

Assemble image path

Kind: static method of sysManage
Returns: string - ImageAddress

Param Type Description
param object
param.avatar string FileAddress
param.type string Types: roster - user, group - group
param.thumbnail boolean Thumbnail or not: true by default
param.sdefault string Default image address

Example

x.avatar = im.sysManage.getImage({
  avatar: x.avatar,
  sdefault: '/static/pages/image/r.png'
});
return x;
res.avatar = this.$store.getters.im.sysManage.getImage({
  avatar: res.avatar,
  type: 'group'
});
this.groupInfo = res;
const uid = this.$store.getters.im.userManage.getUid();
const user = this.getMemberList.find((x) => x.user_id === uid);
this.cardName = (user && (user.display_name || user.name)) || '';
if (!this.cardName) {
  this.$store.getters.im.groupManage
    .asyncGetMemberDisplayName({
      group_id: newSid,
      user_list: [uid]
    })
    .then((res) => {
      if (!res || !res.length) {
        return;
      }
      res.forEach((item) => {
        this.cardName = item.display_name;
      });
    });
}
return this.im.sysManage.getImage({
  avatar
});
return this.im.sysManage.getImage({
  avatar
});
if (!url) {
  const attach = this.message.attach || {};
  url = attach.url;
}
return this.im.sysManage.getImage({ avatar: url, type, thumbnail });
res.avatar = this.$store.getters.im.sysManage.getImage({
  avatar: res.avatar,
  type: 'roster'
});
this.userInfo = res;
const cuid = this.im.userManage.getUid();
const umaps = this.im.rosterManage.getAllRosterDetail();
const fromUid = toNumber(this.message.from);
const fromUserObj = umaps[fromUid] || {};
let username = fromUserObj.username || '';
let avatar = this.im.sysManage.getImage({ avatar: fromUserObj.avatar });

if (fromUid === cuid) {
  username = '我';
} else if (0 == fromUid) {
  username = this.system_roster.name;
  avatar = this.system_roster.avatar;
}
return { username, avatar };
if (!url) {
  const attach = this.message.attach || {};
  url = attach.url;
}
return this.im.sysManage.getImage({ avatar: url, thumbnail });

sysManage.deleteConversation(id, other_devices)

Delete session

Kind: static method of sysManage

Param Type Default Description
id number SessionID
other_devices boolean true Whether to delete conversations on other devices at the same time

Example

const also_delete_other_devices = true;
this.$store.getters.im.sysManage.deleteConversation(id, also_delete_other_devices);
alert('会话删除成功');

this.$store.dispatch('contact/actionGetConversationList');
this.$store.dispatch('header/actionChangeHeaderStatus', 'conversation');
this.$store.dispatch('content/actionSetType', {
  sid: undefined
});
if (this.isOwner) {
  //dismiss
  this.$store.getters.im.groupManage.asyncDestroy({ group_id: this.getSid }).then(() => {
    alert('您已解散了此群。。');
  });
} else {
  //leave
  this.$store.getters.im.groupManage.asyncLeave({ group_id: this.getSid }).then(() => {
    alert('您已退出了此群。。');
  });
}

const also_delete_other_devices = true;
this.$store.getters.im.sysManage.deleteConversation(this.getSid, also_delete_other_devices);
const also_delete_other_devices = true;
this.$store.getters.im.sysManage.deleteConversation(id, also_delete_other_devices);
alert('会话删除成功');

this.$store.dispatch('contact/actionGetConversationList');
this.$store.dispatch('header/actionChangeHeaderStatus', 'conversation');
this.$store.dispatch('content/actionSetType', {
  sid: undefined
});
this.$store.getters.im.rosterManage.asyncDeleteRoster({ user_id: this.getSid }).then(() => {
  alert('好友已删除');
});

const also_delete_other_devices = true;
this.$store.getters.im.sysManage.deleteConversation(this.getSid, also_delete_other_devices);
this.$store.getters.im.rosterManage.asyncDeleteRoster({ user_id: this.getSid }).then(() => {
  alert('好友已删除');
});

const also_delete_other_devices = true;
this.$store.getters.im.sysManage.deleteConversation(this.getSid, also_delete_other_devices);

sysManage.asyncGetGroupAvatarUploadUrl(params) ⇒ Promise.<FileUpload>

Get the URL of uploading group avatar

Kind: static method of sysManage
Returns: Promise.<FileUpload> - File uploading info

Param Type Description
params object Parameter
params.group_id number GroupID

sysManage.asyncGetFileUploadChatFileUrl(params) ⇒ Promise.<FileUpload>

Get upload address of chat file

Kind: static method of sysManage
Returns: Promise.<FileUpload> - File uploading info

Param Type Description
params object Parameter
params.file_type number File types: 100 - general chat file, 101 - voice chat file (amr format), 102 - image chat file, 103 - video chat file, 104 - voice chat file (mp3 format) 200 - general shared file, 201 - voice shared file, 202 - image shared file, 203 - video shared file
params.to_type number Conversation types: 1 - user, 2 - group
params.to_id number SessionID
© 2019-2023 MaximTop | Homepage Last modified time: 2023-08-09 14:48:15

results matching ""

    No results matching ""