Skip to content

Commit

Permalink
revert using new packet for server (#10)
Browse files Browse the repository at this point in the history
* revert using_new_packet_for_server

* 2.0.11
  • Loading branch information
JadlionHD authored Jan 27, 2025
1 parent 228fda8 commit 8c1c563
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "0.0.0"
crate-type = ["cdylib"]

[dependencies]
rusty_enet = { git = "https://github.com/JadlionHD/rusty_enet.git" }
rusty_enet = { git = "https://github.com/StileDevs/rusty_enet.git" }
# rusty_enet = { path = "D:\\Projects\\NodeJS_Projects\\StileDevs\\rusty_enet" }
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
Expand Down
9 changes: 3 additions & 6 deletions lib/structures/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export class Client extends EventEmitter {
port: options?.enet?.port ?? 17091,
maxPeers: options?.enet?.maxPeers ?? 1024,
useNewPacket: {
asClient: options?.enet?.useNewPacket?.asClient ?? false,
asServer: options?.enet?.useNewPacket?.asServer ?? false
asClient: options?.enet?.useNewPacket?.asClient ?? false
},
channelLimit: options?.enet?.channelLimit ?? 2
}
Expand All @@ -28,8 +27,7 @@ export class Client extends EventEmitter {
this.config.enet?.port!,
this.config.enet?.maxPeers!,
this.config.enet?.channelLimit!,
this.config.enet?.useNewPacket?.asClient!,
this.config.enet?.useNewPacket?.asServer!
this.config.enet?.useNewPacket?.asClient!
);
}

Expand Down Expand Up @@ -80,8 +78,7 @@ export class Client extends EventEmitter {
try {
this.host.setEmitter(this.emit.bind(this));

const acceptPromise = () =>
new Promise((resolve) => setImmediate(() => resolve(this.host.service())));
const acceptPromise = () => new Promise((resolve) => setImmediate(() => resolve(this.host.service())));

const loop = async () => {
while (true) await acceptPromise();
Expand Down
2 changes: 1 addition & 1 deletion native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* auto-generated by NAPI-RS */

export declare class Host {
constructor(ipAddress: string, port: number, peerLimit: number, channelLimit: number, usingNewPacket: boolean, usingNewPacketForServer: boolean)
constructor(ipAddress: string, port: number, peerLimit: number, channelLimit: number, usingNewPacket: boolean)
get ipAddress(): string
get port(): number
connect(ipAddress: string, port: number): boolean
Expand Down
2 changes: 1 addition & 1 deletion npm/android-arm-eabi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-android-arm-eabi",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"android"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/android-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-android-arm64",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"android"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-darwin-arm64",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-universal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-darwin-universal",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-darwin-x64",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-arm-gnueabihf",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-arm-musleabihf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-arm-musleabihf",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-arm64-gnu",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-arm64-musl",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-riscv64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-riscv64-gnu",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-x64-gnu",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-linux-x64-musl",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-win32-arm64-msvc",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/win32-ia32-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-win32-ia32-msvc",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growtopia.js-win32-x64-msvc",
"version": "2.0.0",
"version": "2.0.11",
"os": [
"win32"
],
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "growtopia.js",
"description": "A Rust based, cross-platform, high-performance Growtopia private server framework utilizing Node.js, Bun.js.",
"version": "2.0.10",
"version": "2.0.11",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -67,9 +67,10 @@
"scripts": {
"docs": "rimraf docs && typedoc",
"artifacts": "napi artifacts",
"build": "nr build:ts && napi build --platform --js native.js --dts native.d.ts --release",
"build": "nr build:ts && nr build:release",
"build:ts": "rimraf dist && tsc",
"build:debug": "napi build --platform --js native.js --dts native.d.ts ",
"build:debug": "napi build --platform --js native.js --dts native.d.ts",
"build:release": "nr build:debug --release",
"prepublishOnly": "napi prepublish -t npm",
"test": "ava",
"universal": "napi universal",
Expand Down
2 changes: 0 additions & 2 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ impl Host {
peer_limit: u32,
channel_limit: u8,
using_new_packet: bool,
using_new_packet_for_server: bool,
) -> Self {
let host_addr: String = format!("{ip_address}:{port}");

Expand All @@ -44,7 +43,6 @@ impl Host {
compressor: Some(Box::new(enet::RangeCoder::new())),
checksum: Some(Box::new(enet::crc32)),
using_new_packet,
using_new_packet_for_server,
..Default::default()
},
)
Expand Down

0 comments on commit 8c1c563

Please sign in to comment.