// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { UUID, UUIDT } from '../common/uuid.js';


export class BroadcastRequest implements flatbuffers.IUnpackableObject<BroadcastRequestT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):BroadcastRequest {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsBroadcastRequest(bb:flatbuffers.ByteBuffer, obj?:BroadcastRequest):BroadcastRequest {
  return (obj || new BroadcastRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsBroadcastRequest(bb:flatbuffers.ByteBuffer, obj?:BroadcastRequest):BroadcastRequest {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new BroadcastRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

gameId(obj?:UUID):UUID|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}

subject():string|null
subject(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
subject(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

body():string|null
body(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
body(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

static startBroadcastRequest(builder:flatbuffers.Builder) {
  builder.startObject(3);
}

static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
  builder.addFieldStruct(0, gameIdOffset, 0);
}

static addSubject(builder:flatbuffers.Builder, subjectOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, subjectOffset, 0);
}

static addBody(builder:flatbuffers.Builder, bodyOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, bodyOffset, 0);
}

static endBroadcastRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  builder.requiredField(offset, 4) // game_id
  return offset;
}

static createBroadcastRequest(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset, subjectOffset:flatbuffers.Offset, bodyOffset:flatbuffers.Offset):flatbuffers.Offset {
  BroadcastRequest.startBroadcastRequest(builder);
  BroadcastRequest.addGameId(builder, gameIdOffset);
  BroadcastRequest.addSubject(builder, subjectOffset);
  BroadcastRequest.addBody(builder, bodyOffset);
  return BroadcastRequest.endBroadcastRequest(builder);
}

unpack(): BroadcastRequestT {
  return new BroadcastRequestT(
    (this.gameId() !== null ? this.gameId()!.unpack() : null),
    this.subject(),
    this.body()
  );
}


unpackTo(_o: BroadcastRequestT): void {
  _o.gameId = (this.gameId() !== null ? this.gameId()!.unpack() : null);
  _o.subject = this.subject();
  _o.body = this.body();
}
}

export class BroadcastRequestT implements flatbuffers.IGeneratedObject {
constructor(
  public gameId: UUIDT|null = null,
  public subject: string|Uint8Array|null = null,
  public body: string|Uint8Array|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const subject = (this.subject !== null ? builder.createString(this.subject!) : 0);
  const body = (this.body !== null ? builder.createString(this.body!) : 0);

  return BroadcastRequest.createBroadcastRequest(builder,
    (this.gameId !== null ? this.gameId!.pack(builder) : 0),
    subject,
    body
  );
}
}
