chatinstant-messaging

How to Integrate OpenIM in My Web Project for Chat Functionality?


I've successfully deployed the OpenIM server and set up the environment on the server side, but now I'm looking to integrate the client SDK into my project (built with React and Vite) to implement real-time communication. I tried using open-im-sdk-wasm, but I'm encountering issues and am unable to call any API successfully.

enter image description here

I followed the instructions in the documentation for integration, but all attempts have failed. I'm seeking assistance to properly integrate the SDK and, as a starting point, to enable simple sending and receiving of messages with other users.


Solution

  • It seems that you have completed most of the integration work based on the error message screenshot you provided. I think you might not have followed the second step of the SDK Integration Document correctly, which involves importing the necessary static resources. First, you need to copy all files from the node_modules/open-im-sdk-wasm/assets/ directory to your project's public directory:

    openIM.wasm
    sql-wasm.wasm
    wasm_exec.js
    

    Then, you also need to import the wasm_exec.js file into your project using a script tag. This file globally defines the Go object. After importing it, you should be able to get a correct result when calling the SDK.