WuKongIM Docs

Run official examples

Prepare a server and two accounts, run the eight platform examples, and check online bidirectional messaging.

Exchange messages between Alice and Bob before integrating the tutorial code into your application. Choose one platform below; the two clients may also use different platforms.

1. Prepare a development single-node cluster

Follow Docker deployment to start a development single-node cluster. Make WebSocket port 5200 and Product HTTP port 5001 reachable. The default uses 256 hash slots. Keep the server running and check from a trusted development terminal:

curl -fsS http://127.0.0.1:5001/readyz

The readiness request should succeed. The default development URL is ws://127.0.0.1:5200; append /ws only when configured on the listener or proxy. Use WSS for production clients and keep management APIs within your trusted backend.

2. Prepare Alice and Bob

Choose the device category first. The requests below use mobile category 0. Use 1 for Web and 2 for Rust/C#/C++/Python. Set each account’s value separately when platforms differ. alice-token and bob-token are local demonstration values only.

A trusted product backend should prepare each user's uid, token, and WebSocket URL. Only for a loopback development environment, a trusted terminal can call POST /user/token to create test identities. The commands below assume two native clients; change a user's device_flag to 1 when that user signs in through the Web example:

curl -fsS -X POST http://127.0.0.1:5001/user/token \
  -H 'Content-Type: application/json' \
  -d '{"uid":"alice","token":"alice-token","device_flag":0,"device_level":1}'

curl -fsS -X POST http://127.0.0.1:5001/user/token \
  -H 'Content-Type: application/json' \
  -d '{"uid":"bob","token":"bob-token","device_flag":0,"device_level":1}'

Native mobile clients use APP 0, Web uses WEB 1, and desktop uses PC 2. The default product composition exactly validates the stored token for the same UID and device category. A production deployment must still protect this route, implement expiry and rotation policy, and separately prove rejection of invalid, revoked, and product-expired tokens.

Choose the WebSocket URL from where the client runs:

ClientLocal development URL
Browser, Node.js, macOS app, iOS Simulatorws://127.0.0.1:5200
Android Emulatorws://10.0.2.2:5200
Physical phonews://<development-host LAN IP>:5200, with firewall and routing verified

3. Choose and run an example

Prepare the development tools for your platform. Source examples below use pinned versions. To integrate a distributed package into your application, use the install command in its quickstart.

iOS

git clone https://github.com/WuKongIM/WuKongEasySDK-iOS.git
cd WuKongEasySDK-iOS
git checkout v1.1.1
swift build -c release
cd Examples/WuKongIMExample-Unified
./build.sh macos
./build.sh ios

Boot an iOS Simulator, then run:

./build.sh ios --run

You can instead start the macOS variant with ./build.sh macos --run. The iOS ATS cleartext exception in the example exists only for local ws:// development; do not copy it into a production app.

iOS quickstart

Android

git clone https://github.com/WuKongIM/WuKongEasySDK-Android.git
cd WuKongEasySDK-Android
git checkout v1.0.5
./gradlew :example:assembleDebug
./gradlew :example:installDebug

Launch the example on an API 21+ device or emulator. An Android Emulator reaches the host at ws://10.0.2.2:5200, not localhost. Use two devices or emulators for two native identities, or use the browser example as the peer.

Android quickstart

Flutter

git clone https://github.com/WuKongIM/WuKongEasySDK-Flutter.git
cd WuKongEasySDK-Flutter
git checkout v1.1.0
flutter pub get
cd example
flutter pub get
flutter devices
flutter run -d <device-id>

Run every target you intend to ship. An iOS Simulator result cannot stand in for Android, Web, or desktop acceptance.

Flutter quickstart

Web

git clone https://github.com/WuKongIM/WuKongEasySDK-JS.git
cd WuKongEasySDK-JS
git checkout v2.0.5
npm ci
npm run build
python3 -m http.server 8080

Open http://127.0.0.1:8080/example/. Use two isolated browser contexts for Alice and Bob. Do not print tokens or complete payloads to the Console.

Web quickstart

Rust

Requires Rust 1.86+. Check out source matching crates.io 0.1.0:

git clone --branch v0.1.0 --depth 1 https://github.com/WuKongIM/WuKongEasySDK-Rust.git
cd WuKongEasySDK-Rust
cargo build --locked --example chat

In two terminals set WK_WS_URL, WK_UID, WK_TOKEN, and WK_PEER_UID, then run cargo run --locked --example chat. Once both connect, type text and observe received events. Enter /quit to exit.

Rust quickstart

C#

Create MyChat with the complete Program.cs in the C# quickstart and install public NuGet 1.0.0. Set WUKONGIM_WS_URL, WUKONGIM_UID, and WUKONGIM_TOKEN in each terminal:

# Alice
dotnet run --project MyChat -- bob
# Bob
dotnet run --project MyChat -- alice

After both print Connected., press Enter to send and observe Message received. at the peer. Press Enter again after checking both directions to exit.

C# quickstart

C++

Use the C++ quickstart to build my_app with vcpkg, or use wukong_chat from a prebuilt archive. For my_app, set WKIM_URL, WKIM_UID, and WKIM_TOKEN, then run ./build/my_app bob (Bob uses alice). For the archive client, set WKIM_TOKEN and run ./build/wukong_chat ws://127.0.0.1:5200 alice bob.

With my_app, wait for both clients to connect, press Enter to send, then Enter again to exit. With wukong_chat, type messages interactively and /quit to exit. Windows executables are under build/Release/ with an .exe suffix.

C++ quickstart

Python

Run in a Python 3.11+ virtual environment:

python -m pip install --index-url https://pypi.org/simple "wukong-easy-sdk==0.1.0"
git clone --branch v0.1.0 --depth 1 https://github.com/WuKongIM/WuKongEasySDK-Python.git
python WuKongEasySDK-Python/examples/chat.py

First set each terminal’s WKIM_URL, WKIM_UID, WKIM_TOKEN, and WKIM_PEER. Type text after both show Connected; enter /quit to exit.

Python quickstart

4. Check results and exit

  1. Both clients show a successful connection.
  2. Alice receives a server send result, and Bob observes Alice’s message event.
  3. Bob replies and Alice receives it.
  4. Exit using the platform instructions or close the page. Reopening should not leave duplicate events or an old connection.

Example interfaces may display test content; production logs must not record Tokens or full messages.

Troubleshooting

Cannot connect: check /readyz, the reachable address, and ports. Android Emulator uses 10.0.2.2; physical devices use the development machine’s LAN address.

Authentication fails: check UID, Token, and device_flag. Use different UIDs for the two clients.

Send succeeds but nothing arrives: ensure the peer is online, the destination is its UID, and the message listener is registered. SENDACK does not prove recipient delivery.

Messages are missing after being offline: EasySDK does not fetch history. Recover through your backend or choose the full SDK.

Next

Choose a platform and integrate your application. Historical versions and independent source/package results are in engineering validation records. Continue testing WSS, Token rotation, and recovery in your deployment.

On this page