mirror of
https://github.com/DinheroDevelopmentGroup/modular-minecraft-proxy.git
synced 2024-11-27 09:35:49 -05:00
Add proxy packet write helpers
This commit is contained in:
parent
e8c4eaa96f
commit
abb3721b6d
1 changed files with 10 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import type { States } from 'minecraft-protocol';
|
||||
|
||||
import type { EventMap } from '../../util/events.js';
|
||||
import { PublicEventHandler } from '../../util/events.js';
|
||||
import { Packet, type RawPacket } from '../../util/packet.js';
|
||||
|
@ -36,6 +38,14 @@ class ConnectionSide<
|
|||
export const proxy = {
|
||||
upstream: new ConnectionSide<PacketEventMap>('upstream'),
|
||||
downstream: new ConnectionSide<PacketEventMap>('downstream'),
|
||||
writeDownstream(name: string, data: unknown, state?: States): void {
|
||||
const packet = new Packet(name, data, state);
|
||||
proxy.downstream.write(packet);
|
||||
},
|
||||
writeUpstream(name: string, data: unknown, state?: States): void {
|
||||
const packet = new Packet(name, data, state);
|
||||
proxy.upstream.write(packet);
|
||||
},
|
||||
} as const;
|
||||
|
||||
channel.subscribe(({ direction, packet: raw }: Message) => {
|
||||
|
|
Loading…
Reference in a new issue