AlephScript核心
书柜插座。高级IO用于具有命名空间、房间和自动广播等功能的实时应用程序。
安装
npm install @alephscript/coreMonorepo结构
packages/
├── alephscript-core/ # La librería principal
│ ├── src/
│ │ ├── server/ # Clases del servidor
│ │ ├── client/ # Clases del cliente
│ │ ├── types/ # Definiciones de tipos
│ │ └── utils/ # Utilidades
│ └── package.json
└── socket-gym-demo/ # Aplicación demo
├── src/
│ └── index.ts
└── package.json基本用途
服务器
import express from 'express';
import { createServer } from 'node:http';
import { AlephScriptServer } from '@alephscript/core';
const app = express();
const server = createServer(app);
// Crear servidor AlephScript
const as = new AlephScriptServer(server);
server.listen(6000, () => {
console.log('Servidor ejecutándose en puerto 6000');
});客户
import { AlephScriptClient } from '@alephscript/core';
// Crear cliente
const client = new AlephScriptClient(
"MI_CLIENTE",
"http://localhost:6000",
"/runtime"
);
// Configurar triggers de inicialización
client.initTriggersDefinition.push(() => {
client.io.on("SET_SERVER_STATE", (data) => {
console.log("Estado del servidor:", data);
});
// Solicitar estado del servidor
client.room("GET_SERVER_STATE");
});特点
✅ 自动命名空间
/runtime-对于运行时操作/admin-用于管理(带有UI仪表板)/-命名空间基础
✅ 系统主控室
- 自动获取/设置协议
- 对等端之间的消息转发
- 房间自动化管理
✅ 智能 广播
- 事件自动广播
- 系统事件过滤
- 日志记录可配置
✅ 综合监测
- 管理套接字用户界面。包括IO
- 实时连接度量
- 详细服务器状态
可用类型
import {
IUserDetails,
IServerState,
RoomDetails,
INamespaceDetails
} from '@alephscript/core';开发脚本
# Compilar la librería
cd packages/alephscript-core
npm run build
# Ejecutar la demo
cd packages/socket-gym-demo
npm run dev
# Compilar todo el monorepo
npm run build配置类型脚本
该库包括完整类型的定义。要在项目中使用别名:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@alephscript/core": ["./node_modules/@alephscript/core/dist"]
}
}
}完整的例子
版本 packages/socket-gym-demo/src/index.ts 对于完整的实现示例。
许可证
ISC-贡萨洛·贝查拉·巴拉迪
