import { Unreliable , UnreliablePacket } from "./unreliablePacket" ; import { PolusBuffer } from "../util/polusBuffer" ; import { PacketHandler , PacketHandlerOpts , ParsedPacket } from "./packet" ; import { Room } from "../util/room" ; export interface ReliablePacket { Nonce : number ; Data : UnreliablePacket ; } export const Reliable = { parse ( packet , room , opts ) { return { Nonce : packet . readU16 ( true ) , Data : Unreliable . parse ( packet , room , opts ) , } ; } , serialize ( packet , room ) { var buf = new PolusBuffer ( ) ; buf . writeU16 ( packet . Nonce , true ) ; buf . writeBytes ( Unreliable . serialize ( packet . Data as UnreliablePacket , room ) ) ; return buf ; } , } ;