import { CoatyObject , CommunicationEventType , CoreTypes , isPlainObject } from ".." ; import { CommunicationEvent , CommunicationEventData } from "./communication-event" ; /**
 * Advertise event.
 */ export class AdvertiseEvent extends CommunicationEvent < AdvertiseEventData > { get eventType ( ) { return CommunicationEventType . Advertise ; } internal param eventData throws constructor ( eventData ) { super ( eventData ) ; if ( ! CommunicationEvent . isValidEventFilter ( eventData . object . objectType ) ) { throw new TypeError ( `in AdvertiseEvent: invalid objectType ${ eventData . object . objectType }` ) ; } } param object param privateData throws static withObject ( object , privateData ? ) { return new AdvertiseEvent ( new AdvertiseEventData ( object , privateData ) ) ; } } /**
 * Defines event data format for advertising objects.
 */ export class AdvertiseEventData extends CommunicationEventData { private _object : CoatyObject ; private _privateData : { [ key ] : any ; } ; param object param privateData constructor ( object , privateData ? ) { super ( ) ; this . _object = object ; this . _privateData = privateData ; if ( ! this . _hasValidParameters ( ) ) { throw new TypeError ( "in AdvertiseEventData: arguments not valid" ) ; } } internal static createFrom ( eventData ) { return new AdvertiseEventData ( eventData . object , eventData . privateData ) ; } /**
     * The object to be advertised.
     */ get object ( ) { return this . _object ; } /**
     * Application-specific options as an object hash (optional).
     */ get privateData ( ) { return this . _privateData ; } toJsonObject ( ) { return { object : this . _object , privateData : this . _privateData , } ; } private _hasValidParameters ( ) { return CoreTypes . isObject ( this . _object ) && this . _isValidPrivateData ( ) ; } private _isValidPrivateData ( ) { return this . _privateData === undefined || isPlainObject ( this . _privateData ) ; } }