
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
The ioGame TypeScript SDK provides a simple wrapper for interaction between the Netty, WebSocket, Protobuf, TypeScript, and ioGame game servers.
The SDK offers two non-blocking API coding styles for the active request approach. Both can accomplish the same task, and developers can choose to use them according to their own business needs. The interaction APIs provided by the SDK include:
Ts SDK + Code Generation = a variety of advantages
Advantages of SDK Code Generation
About examples
npm i iohao-sdk
// --------- IoGameSetting ---------
ioGameSetting.enableDevMode = true;
// China or Us
ioGameSetting.language = ioGameLanguage.CHINA;
// connect url
ioGameSetting.url = "ws://127.0.0.1:10100/websocket";
ioGameSetting.startNet();
This request method is non-blocking. Developers can set up response callbacks and error callbacks.
// code style: callback. Advantages: simple, integrated.
RequestCommand.ofString(cmdMerge, "hello").onCallback(result => {
console.log(`print-1 ${result.getInt()}`)
}).execute();
// code style: callback. Advantages: simple, integrated.
RequestCommand.ofString(cmdMerge, "hello").onCallback(result => {
// ResponseCallback
console.log(`print-1 ${result.getInt()}`)
}).onError(result => {
// Error Callback
console.log(`errorCode:${result.getResponseStatus()} - `, result.getErrorInfo())
}).execute();
This request method is non-blocking and is implemented using the await Promise mechanism.
// code style: async await. Advantages: Avoid callback hell.
const result = await RequestCommand.ofAwaitString(cmdMerge, "hello");
console.log(`ofAwait-1 ${result.getString()}`);
// code style: async await. Advantages: Avoid callback hell.
const result = await RequestCommand.ofAwaitString(cmdMerge, "hello");
if (result.hasError()) {
// Error process
console.log(`ErrorInfo ${result.getErrorInfo()}`);
}
console.log(`ofAwait-1 ${result.getString()}`);
It is mainly used to listen to the broadcasts from the server. When a broadcast is detected, the corresponding callback method will be triggered.
ListenCommand.of(cmdMerge).onCallback(result => {
// Broadcast Callback
result.log(`Listen ${result.getString()}`);
});
Request/ResponseCallback:Testing of a single object.
const cmd = 1;
// int value
const intValue = 1234;
RequestCommand.ofInt(CmdKit.merge(cmd, 2), intValue).onCallback(result => {
console.log(`ofInt ${result.getInt()}`);
}).execute();
// long value
const longValue = BigInt("9223372036854775807")
RequestCommand.ofLong(CmdKit.merge(cmd, 3), longValue).onCallback(result => {
console.log(`ofLong ${result.getLong()}`);
}).execute();
// boolean value
const boolValue = true;
RequestCommand.ofBool(CmdKit.merge(cmd, 4), boolValue).onCallback(result => {
console.log(`ofBool ${result.getBool()}`);
}).execute();
// string value
const stringValue = "string-000";
RequestCommand.ofString(CmdKit.merge(cmd, 5), stringValue).onCallback(result => {
console.log(`ofString ${result.getString()}`);
}).execute();
// protobuf object
const loginVerify = create(LoginVerifyMessageSchema, {jwt: "1"});
const data = toBinary(LoginVerifyMessageSchema, loginVerify);
RequestCommand.of(CmdKit.merge(cmd, 6), data).onCallback(result => {
// get protobuf object
const message = result.getValue(UserMessageSchema);
console.log(`of`, message);
}).execute();
Request/ResponseCallback:Testing of a single object list.
// list int value
const intList = [1, 23];
RequestCommand.ofIntList(CmdKit.merge(cmd, 12), intList).onCallback(result => {
console.log(`ofIntList ${result.listInt()}`);
}).execute();
// list long value
const longList = [BigInt("9223372036854775800"), BigInt("9223372036854775800")];
RequestCommand.ofLongList(CmdKit.merge(cmd, 13), longList).onCallback(result => {
console.log(`ofLongList ${result.listLong()}`);
}).execute();
// list boolean value
const boolList = [true, false];
RequestCommand.ofBoolList(CmdKit.merge(cmd, 14), boolList).onCallback(result => {
console.log(`ofBoolList ${result.listBool()}`);
}).execute();
// list string value
const stringList = ["string-000", "string-001"];
RequestCommand.ofStringList(CmdKit.merge(cmd, 15), stringList).onCallback(result => {
console.log(`ofStringList ${result.listString()}`);
}).execute();
// list protobuf object
let valueList: Uint8Array[] = [];
for (let i = 0; i < 2; i++) {
const jwt = 10 + i + "";
const loginVerify = create(LoginVerifyMessageSchema, {jwt: jwt});
const data = toBinary(LoginVerifyMessageSchema, loginVerify);
valueList.push(data);
}
RequestCommand.ofValueList(CmdKit.merge(cmd, 16), valueList).onCallback(result => {
const message = result.listValue(UserMessageSchema);
console.log(`ofValueList`, message);
}).execute();
see https://github.com/bufbuild/protobuf-es/blob/main/MANUAL.md#how-to-generate-code
ioGame TypeScript SDK 提供了 Netty、WebScoket、Protobuf、TypeScript、ioGame 游戏服务器交互的简单封装。
SDK 为主动请求的方式提供了非阻塞的两种编码风格的 api,两者可以完成同样的工作,开发者可根据自身业务选择使用。SDK 提供的交互 api 有
SDK 代码生成的几个优势
相关示例
npm i iohao-sdk
// --------- IoGameSetting ---------
ioGameSetting.enableDevMode = true;
// China or Us
ioGameSetting.language = ioGameLanguage.CHINA;
// connect url
ioGameSetting.url = "ws://127.0.0.1:10100/websocket";
ioGameSetting.startNet();
该请求方式是非阻塞的,开发者可设置响应回调与错误回调。
// 【请求-非阻塞】,可设置响应回调与错误回调;优点:简洁,一体化
RequestCommand.ofString(cmdMerge, "hello").onCallback(result => {
console.log(`print-1 ${result.getInt()}`)
}).execute();
// 【请求-非阻塞】,可设置响应回调与错误回调;优点:简洁,一体化
RequestCommand.ofString(cmdMerge, "hello").onCallback(result => {
// 请求回调
console.log(`print-1 ${result.getInt()}`)
}).onError(result => {
// 错误处理回调
console.log(`errorCode:${result.getResponseStatus()} - `, result.getErrorInfo())
}).execute();
该请求方式是非阻塞的,使用 await Promise 机制实现。
// 【请求-非阻塞】,使用 async await 机制;优点:可避免回调地狱
const result = await RequestCommand.ofAwaitString(cmdMerge, "hello");
console.log(`ofAwait-1 ${result.getString()}`);
// 【请求-非阻塞】,使用 async await 机制;优点:可避免回调地狱
const result = await RequestCommand.ofAwaitString(cmdMerge, "hello");
if (result.hasError()) {
// 错误处理
console.log(`ErrorInfo ${result.getErrorInfo()}`);
}
console.log(`ofAwait-1 ${result.getString()}`);
主要用于监听服务器的广播,当监听到广播时,会触发对应的回调方法。
ListenCommand.of(cmdMerge).onCallback(result => {
result.log(`Listen ${result.getString()}`);
});
请求/响应:单个的协议碎片及对象示例。
const cmd = 1;
// int value
const intValue = 1234;
RequestCommand.ofInt(CmdKit.merge(cmd, 2), intValue).onCallback(result => {
console.log(`ofInt ${result.getInt()}`);
}).execute();
// long value
const longValue = BigInt("9223372036854775807")
RequestCommand.ofLong(CmdKit.merge(cmd, 3), longValue).onCallback(result => {
console.log(`ofLong ${result.getLong()}`);
}).execute();
// boolean value
const boolValue = true;
RequestCommand.ofBool(CmdKit.merge(cmd, 4), boolValue).onCallback(result => {
console.log(`ofBool ${result.getBool()}`);
}).execute();
// string value
const stringValue = "string-000";
RequestCommand.ofString(CmdKit.merge(cmd, 5), stringValue).onCallback(result => {
console.log(`ofString ${result.getString()}`);
}).execute();
// protobuf object
const loginVerify = create(LoginVerifyMessageSchema, {jwt: "1"});
const data = toBinary(LoginVerifyMessageSchema, loginVerify);
RequestCommand.of(CmdKit.merge(cmd, 6), data).onCallback(result => {
// get protobuf object
const message = result.getValue(UserMessageSchema);
console.log(`of`, message);
}).execute();
请求/响应:多个的协议碎片及对象示例。
// list int value
const intList = [1, 23];
RequestCommand.ofIntList(CmdKit.merge(cmd, 12), intList).onCallback(result => {
console.log(`ofIntList ${result.listInt()}`);
}).execute();
// list long value
const longList = [BigInt("9223372036854775800"), BigInt("9223372036854775800")];
RequestCommand.ofLongList(CmdKit.merge(cmd, 13), longList).onCallback(result => {
console.log(`ofLongList ${result.listLong()}`);
}).execute();
// list boolean value
const boolList = [true, false];
RequestCommand.ofBoolList(CmdKit.merge(cmd, 14), boolList).onCallback(result => {
console.log(`ofBoolList ${result.listBool()}`);
}).execute();
// list string value
const stringList = ["string-000", "string-001"];
RequestCommand.ofStringList(CmdKit.merge(cmd, 15), stringList).onCallback(result => {
console.log(`ofStringList ${result.listString()}`);
}).execute();
// list protobuf object
let valueList: Uint8Array[] = [];
for (let i = 0; i < 2; i++) {
const jwt = 10 + i + "";
const loginVerify = create(LoginVerifyMessageSchema, {jwt: jwt});
const data = toBinary(LoginVerifyMessageSchema, loginVerify);
valueList.push(data);
}
RequestCommand.ofValueList(CmdKit.merge(cmd, 16), valueList).onCallback(result => {
const message = result.listValue(UserMessageSchema);
console.log(`ofValueList`, message);
}).execute();
see https://github.com/bufbuild/protobuf-es/blob/main/MANUAL.md#how-to-generate-code
FAQs
ioGame TypeScript SDK; Protobuf、Netty、WebSocket
We found that iohao-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.