npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

that-sky-cross-sdk

v1.0.0

Published

That Sky Cross SDK - 跨游戏服务器数据互联同步SDK

Readme

That Sky Cross SDK

跨游戏服务器数据互联同步 SDK

安装

npm install that-sky-cross-sdk

快速开始

import ThatSkyCrossSDK from 'that-sky-cross-sdk';

const sdk = new ThatSkyCrossSDK({
  nodeEndpoint: 'ws://localhost:3001/ws',
  nodeSecret: 'your-secret-key',
  reconnect: true
});

// 连接
await sdk.connect();

// 加入房间
const room = await sdk.join({
  roomId: 'battle_room_001',
  protocolType: 'battle_sync'
});

// 更新数据
await sdk.update({
  path: '/account/player/player_001',
  playerId: 'player_001',
  data: {
    name: 'Player One',
    level: 50,
    hp: 100
  }
});

// 同步数据
const playerData = await sdk.sync({
  path: '/account/player/player_001',
  playerId: 'player_001'
});

// 监听数据更新
sdk.on('data_update', (data) => {
  console.log('Data updated:', data);
});

// 离开房间
await sdk.leave('battle_room_001');

// 断开连接
sdk.disconnect();

API 文档

构造函数

const sdk = new ThatSkyCrossSDK({
  nodeEndpoint: string;      // 节点服务器地址
  nodeSecret: string;        // 预共享密钥
  serverId?: string;         // 服务器ID(可选)
  reconnect?: boolean;       // 自动重连(默认 true)
  reconnectInterval?: number; // 重连间隔(默认 5000ms)
  maxReconnectAttempts?: number; // 最大重连次数(默认 5)
  timeout?: number;          // 请求超时(默认 5000ms)
});

方法

connect()

连接到节点服务器。

await sdk.connect();

join(request)

加入房间(不存在则创建)。

const room = await sdk.join({
  roomId: string;
  protocolType: string;
  metadata?: object;
});

leave(roomId)

离开房间。

await sdk.leave(roomId);

update(request)

更新数据。

await sdk.update({
  path: string;              // 数据路径
  playerId: string;          // 玩家ID
  data: unknown;             // 数据内容
  options?: {
    ttl?: number;            // 有效期(秒)
    broadcast?: boolean;     // 是否广播
  }
});

sync(request)

同步数据(实时获取最新数据)。

const data = await sdk.sync({
  path: string;
  playerId: string;
  options?: {
    timeout?: number;
  }
});

syncBatch(requests)

批量同步数据。

const results = await sdk.syncBatch([
  { path: '/account/player/1', playerId: '1' },
  { path: '/account/player/2', playerId: '2' }
]);

delete(path)

删除数据。

await sdk.delete(path);

disconnect()

断开连接。

sdk.disconnect();

事件

// 连接成功
sdk.on('connected', () => {});

// 断开连接
sdk.on('disconnected', () => {});

// 错误
sdk.on('error', (error: Error) => {});

// 认证成功
sdk.on('authenticated', (serverId: string) => {});

// 数据更新
sdk.on('data_update', (data: DataPushMessage) => {});

// 成员加入
sdk.on('member_join', (member: MemberInfo) => {});

// 成员离开
sdk.on('member_leave', (member: MemberInfo) => {});

License

MIT