
class BridgeData {
  protected bridgeDataSet: BridgeDataSet

  constructor(messageData: any) {
    if( messageData?.type === "video" ) {
      this.bridgeDataSet = new VideoBridgeDataSet(messageData)
    }
    else if( messageData?.type === "object" ) {
      this.bridgeDataSet = new ObjectBridgeDataSet(messageData)
    }
  }

  public getMessageProcess() : BridgeDataSet {
    return this.bridgeDataSet
  }
}

interface BridgeDataSet {
  getDefaultData(): any
}

class VideoBridgeDataSet implements BridgeDataSet {
  private messageData: any

  constructor(messageData: any) {
    this.messageData = messageData
  }

  public getDefaultData() : any {
    return this.messageData.frame
  }

  public getWidth(): number {
    return this.messageData?.width
  }

  public getHeight(): number {
    return this.messageData?.height
  }
}

class ObjectBridgeDataSet implements BridgeDataSet {
  private messageData: any

  constructor(messageData: any) {
    this.messageData = messageData
  }

  public getDefaultData() : any {
    return JSON.parse(this.messageData.objectData.toString())
  }
}





