Home Reference Source Test
import Bundle from 'osc-js/src/bundle.js'
public class | source

Bundle

An OSC Bundle consist of a Timetag and one or many Bundle Elements. The elements are either OSC Messages or more OSC Bundles

Test:

Constructor Summary

Public Constructor
public

constructor(args: ...*)

Create a Bundle instance

Member Summary

Public Members
public
public
Private Members
private

Method Summary

Public Methods
public

add(item: Bundle | Message)

Add a Message or Bundle to the list of elements

public

Interpret the Bundle as packed binary data

public

Take a JavaScript timestamp to set the Bundle's timetag

public

unpack(dataView: DataView, initialOffset: number): number

Unpack binary data to read a Bundle

Public Constructors

public constructor(args: ...*) source

Create a Bundle instance

Params:

NameTypeAttributeDescription
args ...*
  • optional

Timetag and elements. See examples for options

Example:

const bundle = new Bundle(new Date() + 500)
const message = new Message('/test/path', 51.2)
const anotherBundle = new Bundle([message], Date.now() + 1500)
const message = new Message('/test/path', 51.2)
const anotherMessage = new Message('/test/message', 'test', 12)
const anotherBundle = new Bundle(message, anotherMessage)

Public Members

public bundleElements: array source

public timetag: AtomicTimetag source

Private Members

private offset: number source

Public Methods

public add(item: Bundle | Message) source

Add a Message or Bundle to the list of elements

Params:

NameTypeAttributeDescription
item Bundle | Message

public pack(): Uint8Array source

Interpret the Bundle as packed binary data

Return:

Uint8Array

Packed binary data

public timestamp(ms: number) source

Take a JavaScript timestamp to set the Bundle's timetag

Params:

NameTypeAttributeDescription
ms number

JS timestamp in milliseconds

Example:

const bundle = new Bundle()
bundle.timestamp(Date.now() + 5000) // in 5 seconds

public unpack(dataView: DataView, initialOffset: number): number source

Unpack binary data to read a Bundle

Params:

NameTypeAttributeDescription
dataView DataView

The DataView holding the binary representation of a Bundle

initialOffset number
  • optional
  • default: 0

Offset of DataView before unpacking

Return:

number

Offset after unpacking