UNPKG

mediasoup

Version:

Cutting Edge WebRTC Video Conferencing

109 lines (108 loc) 4.17 kB
"use strict"; // automatically generated by the FlatBuffers compiler, do not modify Object.defineProperty(exports, "__esModule", { value: true }); exports.NotificationT = exports.Notification = void 0; /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ const flatbuffers = require("flatbuffers"); const body_1 = require("../../fbs/notification/body"); const event_1 = require("../../fbs/notification/event"); class Notification { bb = null; bb_pos = 0; __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsNotification(bb, obj) { return (obj || new Notification()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsNotification(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new Notification()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } handlerId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } event() { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.readUint8(this.bb_pos + offset) : event_1.Event.WORKER_CLOSE; } bodyType() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.readUint8(this.bb_pos + offset) : body_1.Body.NONE; } body(obj) { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; } static startNotification(builder) { builder.startObject(4); } static addHandlerId(builder, handlerIdOffset) { builder.addFieldOffset(0, handlerIdOffset, 0); } static addEvent(builder, event) { builder.addFieldInt8(1, event, event_1.Event.WORKER_CLOSE); } static addBodyType(builder, bodyType) { builder.addFieldInt8(2, bodyType, body_1.Body.NONE); } static addBody(builder, bodyOffset) { builder.addFieldOffset(3, bodyOffset, 0); } static endNotification(builder) { const offset = builder.endObject(); builder.requiredField(offset, 4); // handler_id return offset; } static createNotification(builder, handlerIdOffset, event, bodyType, bodyOffset) { Notification.startNotification(builder); Notification.addHandlerId(builder, handlerIdOffset); Notification.addEvent(builder, event); Notification.addBodyType(builder, bodyType); Notification.addBody(builder, bodyOffset); return Notification.endNotification(builder); } unpack() { return new NotificationT(this.handlerId(), this.event(), this.bodyType(), (() => { const temp = (0, body_1.unionToBody)(this.bodyType(), this.body.bind(this)); if (temp === null) { return null; } return temp.unpack(); })()); } unpackTo(_o) { _o.handlerId = this.handlerId(); _o.event = this.event(); _o.bodyType = this.bodyType(); _o.body = (() => { const temp = (0, body_1.unionToBody)(this.bodyType(), this.body.bind(this)); if (temp === null) { return null; } return temp.unpack(); })(); } } exports.Notification = Notification; class NotificationT { handlerId; event; bodyType; body; constructor(handlerId = null, event = event_1.Event.WORKER_CLOSE, bodyType = body_1.Body.NONE, body = null) { this.handlerId = handlerId; this.event = event; this.bodyType = bodyType; this.body = body; } pack(builder) { const handlerId = (this.handlerId !== null ? builder.createString(this.handlerId) : 0); const body = builder.createObjectOffset(this.body); return Notification.createNotification(builder, handlerId, this.event, this.bodyType, body); } } exports.NotificationT = NotificationT;