Registry / gaming / iohao-sdk

iohao-sdk

JSON →
library21.0.1jsnpmunverified

The ioGame TypeScript SDK (iohao-sdk) at version 21.0.1 provides a non-blocking client interface for interacting with ioGame game servers over WebSocket and Protobuf. It offers two API styles: callback-based and async/await, plus broadcast listening and error handling. Key differentiators include code generation support that reduces boilerplate and enforces type safety, making server-client integration more like local method calls. The SDK is TypeScript-first with bundled types, and supports Cocos Creator, Vue, and plain HTML/TS projects. It is actively maintained by ioGame team with regular releases.

npm install iohao-sdk
INSTALL
IMPORT
SIG · IOHAO-SDK
I
iohao-sdk
gamingjavascriptv21.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ioGameSetting
import { ioGameSetting } from 'iohao-sdk'
const ioGameSetting = require('iohao-sdk')
Named export for global configuration; must be used to set URL and start connection.
RequestCommand
import { RequestCommand } from 'iohao-sdk'
Main class for sending requests with callbacks or async/await.
ListenCommand
import { ListenCommand } from 'iohao-sdk'
Used to register broadcast listeners from the server.
ioGameLanguage
import { ioGameLanguage } from 'iohao-sdk'
import { ioGameLanguage } from 'iohao-sdk/ioGameLanguage'
Enum for language settings (CHINA/US).

Shows how to configure the SDK, connect via WebSocket, send requests using both callback and async/await styles, and listen for broadcasts.

import { ioGameSetting, ioGameLanguage, RequestCommand, ListenCommand } from 'iohao-sdk'; // Configure and connect ioGameSetting.enableDevMode = true; ioGameSetting.language = ioGameLanguage.CHINA; ioGameSetting.url = 'ws://127.0.0.1:10100/websocket'; ioGameSetting.startNet(); // Callback style RequestCommand.ofString(301, 'hello').onCallback(result => { console.log(result.getInt()); }).execute(); // Async/await style const result = await RequestCommand.ofAwaitString(301, 'hello'); if (!result.hasError()) { console.log(result.getString()); } // Broadcast listener ListenCommand.of(301).onCallback(result => { console.log('Broadcast received:', result.getString()); });
Debug
Known issues
gotchaThe SDK requires a game server running ioGame; it will not work with arbitrary WebSocket servers.
fix
Ensure the server is an ioGame instance with WebSocket support.
affects: >=0.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: ioGameSetting is not defined
Imported incorrectly as default or not at all.
fix
Use import { ioGameSetting } from 'iohao-sdk';
Error: Cannot read properties of undefined (reading 'onCallback')
Calling onCallback before execute() on RequestCommand.
fix
Chain methods correctly: RequestCommand.ofString(...).onCallback(...).execute();
Upgrade
Version history
21.0.1latest on npm
Audit
Dependencies
protobufjsrequiredProtobuf serialization/deserialization for binary protocol
Agent activity
49 hits · last 30 days
node
46
Resources
iohao-sdk — npm install iohao-sdk · libregistry