Skip to content

[BUG] It can not createMessage #148

@timothyzhao0507

Description

@timothyzhao0507

OpenIM Server Version

Server: 3.8.1, Web: 3.8.2

Operating System and CPU Architecture

macOS (ARM)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

I use Quasar+Vite+VUE to develop the Web IM following documents.
But it report errors when createTextMessage. My Code:

`
import {onBeforeMount, reactive, ref} from "vue";
import {Notify, useMeta} from "quasar";
import {CbEvents, getSDK} from "@openim/wasm-client-sdk";
import {CURRENT_USER, IM_TOKEN, ImApi, ImWs} from "src/js/Constants.js";
import Message from "src/js/Message.js";

defineOptions({
name: 'Chat'
});
useMeta({
title: 'Chatting'
});

const IMSDK = getSDK({
coreWasmPath: "/openIM.wasm",
sqlWasmPath: "/sql-wasm.wasm",
debug: true, //Debug日志
});

IMSDK.on(CbEvents.OnRecvNewMessages, ({data: messages}) => {
console.log(messages);
Notify.create({
type: 'positive',
message: messages
});
});

const CurrUser = reactive(JSON.parse(sessionStorage.getItem(CURRENT_USER)));
const ImToken = sessionStorage.getItem(IM_TOKEN);
const loading = ref(false);
const message = reactive(new Message());
message.msg = "Hello IM";
// console.log(CurrUser.id, CurrUser.username); //TODO:user

const onSendMsg = async () => {
loading.value = true;
const msg = await IMSDK.createTextMessage("Hello OpenIM");
console.log("TextMessage",msg); //TODO:TextMessage
await IMSDK.sendMessage({
recvID: "member", //TODO:接收方ID
groupID: "",
message: msg.data
}).then(res => {
console.log("sent", res);
}).catch((code, msg) => {
console.error(code, msg);
});
loading.value = false;
};

IMSDK.on(CbEvents.OnConnecting, () => {
console.log("Connecting...");
});
IMSDK.on(CbEvents.OnConnectSuccess, () => {
console.log("Connected");
});
IMSDK.on(CbEvents.OnConnectFailed, () => {
console.log("Connect Failed");
});
IMSDK.on(CbEvents.OnUserTokenExpired, () => {
console.log("User Token Expired ...");
});

onBeforeMount(async () => {
console.log("准备登录",ImApi, ImWs); //TODO:准备登录
await IMSDK.login({
userID: CurrUser.id, //IM userID
token: ImToken, //IM User Token
apiAddr: ImApi, //IM API 地址,一般为http://domain:10002
wsAddr: ImWs, //IM WS 地址,一般为ws://domain:10001
platformID: 5 //当前登录平台号(Web端为5)
}).then((res) => {
console.log("success", res);
}).catch(({code, msg}) => {
console.error(code, msg);
});
console.log("登录完成",ImApi, ImWs); //TODO:登录完成
});
`

Screenshots Link

Console

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions