import ip from 'ip' ; import { WritableStreamBuffer } from 'stream-buffers' ; import { PacketId } from 'packets/definitions' ; import { OutPacketBase } from 'packets/out/packet' ; class export class OutUdpPacket extends OutPacketBase { constructor ( isHost , userId , ipAddress , port ) { super ( PacketId . Udp ) ; this . outStream = new WritableStreamBuffer ( { initialSize : 32 , incrementAmount : 8 } ) ; this . buildHeader ( ) ; this . writeUInt8 ( 1 ) ; this . writeUInt8 ( isHost ? 1 : 0 ) ; this . writeUInt32 ( userId ) ; this . writeUInt32 ( ip . toLong ( ipAddress ) , false ) ; this . writeUInt16 ( port ) ; } }