@2003scape/rsc-data-server 中文文档教程

发布于 4年前 浏览 25 项目主页 更新于 3年前

rsc-data-server

管理 rsc-server 世界, 播放器存储、朋友交流等。jagex 将其称为 登录服务器。 此服务器使用 JSON 通过 IPC 的 TCP 或 UNIX 文件套接字与 rsc-server 通信。

install

# npm install @2003scape/rsc-data-server # -g for the CLI program

usage

const Server = require('@2003scape/rsc-data-server');
const fs = require('fs').promises;

(async () => {
    const config = JSON.parse(await fs.readFile('./config.json'));
    const server = new Server(config);
    await server.init();
})();

cli usage

$ rsc-data-server -c /etc/rsc-data-server/config.json

configuration

{
    "sockFile": "/tmp/rsc-data-server.sock", // unix IPC socket files
    "port": 8001, // optional TCP port
    "sqliteFile": "./rsc-data-server.sqlite",
    // default is "test"
    "password": "$2y$10$wufvP1CJMLYmBHKl2Ah2k.CGQwQV5aUMIcXrPNUfmqJ9ibNhhvFnS",
    "passwordHashRounds": 12,
    "recoveryHashRounds": 15,
    "playersPerIp": 1
}

handlers

rsc-data-server 响应 JSON 消息,将 .handler 属性设置为 以下内容:

authenticate

验证 rsc-server 或 rsc-www 实例以允许其余的处理程序 要使用的。

{
    handler; 'authenticate',
    password: 'test'
}

返回:

{
    success: true, // or false
    error: '' // if success false
}

worldConnect

初始化一个 rsc-server 供玩家登录。

{
    handler; 'worldConnect',
    id: 1, // 1-254
    tcpPort: 43594,
    websocketPort: 43595,
    members: false, // or true
    country: 'CAN' // ISO 3166-1 alpha-3
}

返回:

{
    success: true, // or false
    error: '' // if success false
}

worldDisconnect

断开 rsc-server 实例。 如果连接是自动发生 下降。

{
    handler: 'worldDisconnect'
}

worldGetList

获取世界列表。

返回:

[
    {
        id: 1,
        members: false,
        country: 'CAN',
        online: true,
        players: 0 // to 1250
    }
]

playerCount

注册玩家总数。

{
    handler: 'playerCount'
}

playerOnlineCount

每个世界在线玩家的数量。

{
    handler: 'playerOnlineCount'
}

playerRegister

{
    handler: 'playerRegister'
    username: '',
    password: '',
    ip: ''
}

返回:

{
    success: true, // or false
    code: 0 // used in the client to display error message or indicate success
}

playerLogin

检查玩家的凭证是否正确以及他们是否被允许进入 他们正在登录的世界(会员资格检查)。

{
    handler: 'playerLogin',
    username: '',
    password: '',
    ip: ''
}

返回:

{
    success: true, // or false
    code: 0 // similar to registration code
    player: {
        id: 1,
        bank: [ { id: 10, amount: 1000 } ],
        inventory: [ { id: 10, amount: 1000 } ],
        skills: { attack: { current: 1, experience: 332 } },
        // etc.
    } // undefined if invalid credentials
}

playerMessage

向另一个世界的玩家发送消息。

{
    handler: 'playerMessage',
    fromUsername: '',
    toUsername: '',
    message: ''
}

返回:

{
    success: true, // or false
    error: '' // if success false
}

senders

rsc-data-server 将这些发送给某些(或所有)带有每个标头的客户端 对应.handler属性:

playerLogin

玩家登录时发送给rsc-server实例。

{
    handler: 'playerLoggedIn',
    username: '',
    world: 1 // up to 254
}

playerMessage

发送到世界对应的rsc-server实例 toUsername 驻留在 playerMessage 处理程序中。

{
    handler: 'playerMessage',
    fromUsername: '',
    toUsername: '',
    message: ''
}

license

版权所有 (C) 2020 2003Scape Team

本程序是免费软件:您可以重新分发和/或修改 它根据 GNU Affero 通用公共许可证的条款作为 由自由软件基金会发布,无论是第 3 版 许可,或(由您选择)任何更高版本。

这个程序是分发的,希望它有用, 但没有任何保证; 甚至没有默示保证 特定用途的适销性或适用性。 见 GNU Affero 通用公共许可证了解更多详情。

您应该已经收到 GNU Affero 通用公共许可证的副本 随着这个程序。 如果没有,请参阅 http://www.gnu.org/licenses/。

rsc-data-server

manage rsc-server worlds, player storage, friend communication, etc. jagex refered to theirs as the loginserver. this server uses JSON to communicate with rsc-server over TCP or UNIX file sockets for IPC.

install

# npm install @2003scape/rsc-data-server # -g for the CLI program

usage

const Server = require('@2003scape/rsc-data-server');
const fs = require('fs').promises;

(async () => {
    const config = JSON.parse(await fs.readFile('./config.json'));
    const server = new Server(config);
    await server.init();
})();

cli usage

$ rsc-data-server -c /etc/rsc-data-server/config.json

configuration

{
    "sockFile": "/tmp/rsc-data-server.sock", // unix IPC socket files
    "port": 8001, // optional TCP port
    "sqliteFile": "./rsc-data-server.sqlite",
    // default is "test"
    "password": "$2y$10$wufvP1CJMLYmBHKl2Ah2k.CGQwQV5aUMIcXrPNUfmqJ9ibNhhvFnS",
    "passwordHashRounds": 12,
    "recoveryHashRounds": 15,
    "playersPerIp": 1
}

handlers

rsc-data-server responds to JSON messages with the .handler property set to the following:

authenticate

authenticate rsc-server or rsc-www instance to allow the rest of the handlers to be used.

{
    handler; 'authenticate',
    password: 'test'
}

returns:

{
    success: true, // or false
    error: '' // if success false
}

worldConnect

initialize an rsc-server for players to login to.

{
    handler; 'worldConnect',
    id: 1, // 1-254
    tcpPort: 43594,
    websocketPort: 43595,
    members: false, // or true
    country: 'CAN' // ISO 3166-1 alpha-3
}

returns:

{
    success: true, // or false
    error: '' // if success false
}

worldDisconnect

disconnect an rsc-server instance. happens automatically if the connection is dropped.

{
    handler: 'worldDisconnect'
}

worldGetList

get a list of worlds.

returns:

[
    {
        id: 1,
        members: false,
        country: 'CAN',
        online: true,
        players: 0 // to 1250
    }
]

playerCount

the total number of registered players.

{
    handler: 'playerCount'
}

playerOnlineCount

the number of players online in each world.

{
    handler: 'playerOnlineCount'
}

playerRegister

{
    handler: 'playerRegister'
    username: '',
    password: '',
    ip: ''
}

returns:

{
    success: true, // or false
    code: 0 // used in the client to display error message or indicate success
}

playerLogin

checks if a player's credentials are correct and if they're allowed onto the world they're logging into (membership check).

{
    handler: 'playerLogin',
    username: '',
    password: '',
    ip: ''
}

returns:

{
    success: true, // or false
    code: 0 // similar to registration code
    player: {
        id: 1,
        bank: [ { id: 10, amount: 1000 } ],
        inventory: [ { id: 10, amount: 1000 } ],
        skills: { attack: { current: 1, experience: 332 } },
        // etc.
    } // undefined if invalid credentials
}

playerMessage

send a message to a player on another world.

{
    handler: 'playerMessage',
    fromUsername: '',
    toUsername: '',
    message: ''
}

returns:

{
    success: true, // or false
    error: '' // if success false
}

senders

rsc-data-server sends these to certain (or all) clients with the each header corresponding to the .handler property:

playerLogin

sent to rsc-server instances when players login.

{
    handler: 'playerLoggedIn',
    username: '',
    world: 1 // up to 254
}

playerMessage

sent to the rsc-server instance corresponding to the the world toUsername resides in the playerMessage handler.

{
    handler: 'playerMessage',
    fromUsername: '',
    toUsername: '',
    message: ''
}

license

Copyright (C) 2020 2003Scape Team

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文