Skip to content

Commit

Permalink
use newer Serenity Raknet.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Jul 17, 2024
1 parent 2487888 commit 764fc5c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanctumterra/raknet",
"version": "1.0.13",
"version": "1.0.14",
"description": "",
"main": "dist/index.js",
"emitDeclarationOnly": true,
Expand All @@ -24,9 +24,8 @@
},
"dependencies": {
"@serenityjs/binarystream": "^2.6.6",
"@serenityjs/raknet": "0.4.0-beta-20240715032912",
"@serenityjs/raknet": "^0.4.1-beta-20240717055334",
"chalk": "^4.1.2",
"i": "^0.3.7",
"npm": "^10.8.2",
"path": "^0.12.7"
}
Expand Down
15 changes: 14 additions & 1 deletion src/client/FrameHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import { Ack, Address, ConnectedPing, ConnectedPong, ConnectionRequestAccepted, Frame, FrameSet, Nack, Packet, Priority, Reliability, Status } from "@serenityjs/raknet";
import {
Ack,
Address,
ConnectedPing,
ConnectedPong,
ConnectionRequestAccepted,
Frame,
FrameSet,
Nack,
Packet,
Priority,
Reliability,
Status
} from "@serenityjs/raknet";
import { RakNetClient } from "./RaknetClient";
import { OhMyNewIncommingConnection } from "../packets/raknet/OhMyNewIncommingConnection";
import { BinaryStream } from "@serenityjs/binarystream";
Expand Down
12 changes: 4 additions & 8 deletions src/client/PacketHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {
Ack,
import {
Address,
MAX_MTU_SIZE,
DGRAM_MTU_OVERHEAD,
Frame,
Nack,
OpenConnectionReply1,
OpenConnectionRequest1,
OpenConnectionRequest2,
Expand Down Expand Up @@ -34,7 +30,7 @@ export class PacketHandler {
if(!ignore.includes(packetId)) Logger.debug("Received Packet ID " + packetId)

switch (packetId) {
case Bitflags.Valid+44:
case Bitflags.Valid:
this.framehandler.handleFrameSet(buffer);
break;
case Packet.OpenConnectionReply1:
Expand All @@ -44,7 +40,7 @@ export class PacketHandler {
this.handleOpenConnectionRequest();
break;
default:
this.otherPackets(buffer)
this.otherPackets(buffer);
Logger.debug('Received unknown packet ' + packetId);
}
}
Expand Down Expand Up @@ -99,7 +95,7 @@ export class PacketHandler {
"binary"
);
packet.protocol = this.client.protocol;
packet.mtu = 1024-DGRAM_MTU_OVERHEAD;
packet.mtu = 1024 - 36;
const serializedPacket = packet.serialize();
this.client.send(serializedPacket);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Queue {
private queueFrame(frame: Frame, priority: Priority): void {
let length = DGRAM_HEADER_SIZE;
for (const frame of this.outputFrames) length += frame.getByteLength();
if (length + frame.getByteLength() > this.mtu - DGRAM_MTU_OVERHEAD)
if (length + frame.getByteLength() > this.mtu - 36)
this.sendQueue(this.outputFrames.size);
this.outputFrames.add(frame);
if (priority === Priority.Immediate) return this.sendQueue(1);
Expand Down

0 comments on commit 764fc5c

Please sign in to comment.