-
Notifications
You must be signed in to change notification settings - Fork 0
Node.JS & Deno Edition
Trollhunters501PC edited this page Dec 16, 2024
·
6 revisions
In your script add this with NPM installed
npm Command:
npm install https://github.com/Creadores-Program/ServerWebGamePost/releases/download/1.1.1/ServerWebGamePost-1.1.1.Nodejs.Edition.tgz
package.json:
"dependencies":{
"ServerWebGamePost": "1.1.1"
}
Script:
const ServerWebGamePost = requiere("ServerWebGamePost");
deno.json:
{
"nodeModulesDir": true
}
Script:
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const ServerWebGamePost = require("ServerWebGamePost");
You need to create a callback function. Something like that:
function processDatapacks(datapack){
//datapack = json
}
You can use the sendDataPacket function of the Server class:
//server = ServerWebGamePost.Server Instance
server.sendDataPacket(datapack.identifier, {
key: "data..."
});
//first argument = String(client identifier), Second argument = json(Datapacket)
You must create a new ServerWebGamePost.Server instance
var Server = new ServerWebGamePost.Server(port, imgSrc, procecerDatapacks);
// port = Number(port where the server will open), imgSrc String (Server icon directory can be null), procecerDatapacks function(Callback for handling data packets)
If you want to implement HTTPS just use the http API
Get the http server:
//server = ServerWebGamePost.Server instance
server.getHttpServer();
just run the stop function in the Server class
Same as the server
function processDatapacks(datapack){
//datapack = json
}
Simply in the ServerWebGamePost.Client class Execute the sendDatapacket function
Something like that:
//client = ServerWebGamePost.Client
client.sendDatapacket(packet);
//packet = json
// Remember to also send the identifier key
You must create a new ServerWebGamePost.Client instance
var client = new ServerWebGamePost.Client(domain, port, isHttps);
// domain = String (server domain or IP)
// port = Number (Server port)
// isHttps= boolean (whether the server has HTTPS encryption or not)
client.processDatapacks = callback;
//callback = function(Callback in charge of handling data packets )