1.0.16 • Published 10 months ago

rsemu-library v1.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

RSEmuLib

To install this lib just use npm install rsemu-library or yarn add rsemu-library

Starting a TCP server

You can open a TCP server fallowing this basic example.

import {RSLIB} from 'rsemu-library/dist/RSLIB'
import IPacketHandler from 'rsemu-library/dist/source/server/IPacketHandler';

(async() => {
    const handlers : Array<IPacketHandler> = []
    RSLIB.Network.startServer('0.0.0.0', 55661, handlers)
})()

To handler network packets received by server, use IPacketHandler interface to implemenet interceptor objects.

export default interface IPacketHandler {
    packet : Buffer | undefined
    client : Client | undefined
    setParams(packet : Buffer, client : Client) : void
    sendResponse() : void
}

Take a look on example bellow

import {RSLIB} from 'rsemu-library/dist/RSLIB'
import Client from 'rsemu-library/dist/source/server/Client';
import IPacketHandler from 'rsemu-library/dist/source/server/IPacketHandler';

(async() => {

    class ServerList implements IPacketHandler {
        packet: Buffer | undefined;
        client: Client | undefined;
        setParams(packet: Buffer, client: Client): void {
            this.packet = packet
            this.client = client
        }
        sendResponse(): void {
            console.log('Working!');
            //Response example
            client.socket.write(Buffer.from('000000', 'hex'))
        }
    }
  
    const handlers : Array<IPacketHandler> = []
    handlers[4096] = new ServerList()
  
    RSLIB.Network.startServer('0.0.0.0', 55661, handlers)

})()

You can also decrypt a network packet

npm.io

And you can write data too using Writer

npm.io

Loading items info

To load items data just use example below

npm.io

1.0.16

10 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.15

10 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago