AddrBook:
Filter:
Utopia/Classes (extension) | Utopia | External Control > OSC

AddrBook
ExtensionExtension

Dictionary of networked Peers

Description

AddrBook is essentially a dictionary of Peer instances, which represent participants or nodes in a networked music system. AddrBook is not a singleton, and a given system could use multiple instances of it to represent different subgroups, etc. Most objects in Utopia take an AddrBook as an argument, and respond to changes in it when appropriate. An AddrBook is generally used as a (possibly dynamic) collection of intended recipients for one or more types of communication.

Class Methods

.new

Create a new instance.

Returns:

An AddrBook

Instance Methods

.add

Add a Peer to this AddrBook.

Arguments:

peer

The Peer to add.

.remove

Remove a Peer from this AddrBook.

Arguments:

peer

The Peer to remove.

.removeAt

Remove a Peer from this AddrBook, specified by name.

Arguments:

name

A Symbol corresponding to the name of the Peer to remove.

.addMe

Add a Peer to this AddrBook which represents the localhost.

Arguments:

mePeer

An optional Peer to add as me. If nil this method will automatically create a Peer, whose name var will be set using the 'whoami' command line utility.

.send

Send an OSC message to one of the Peers in this AddrBook.

Arguments:

name

A Symbol corresponding to the name of the Peer to whom the message should be sent.

 ... msg

One or more additional arguments comprising the OSC message to send.

.sendAll

Send an OSC message to all of the Peers in this AddrBook.

Arguments:

 ... msg

One or more arguments comprising the OSC message to send.

.sendAllBundle

Send an OSC bundle to all of the Peers in this AddrBook.

Arguments:

time

The timestamp for the bundle, specified as some number of seconds into the future. A nil time indicates 'as soon as possible'.

 ... msg

One or more Arrays consisting of the OSC messages in the bundle.

.sendExcluding

Send an OSC message to all of the Peers in this AddrBook, except for the one specified by name.

Arguments:

name

A Symbol corresponding to the name of the Peer to whom the message should not be sent.

 ... msg

One or more arguments comprising the OSC message to send.

.at

Look up a Peer by name.

Arguments:

name

A Symbol corresponding to the name of the Peer to look up.

Returns:

A Peer if one with the specified name is found, otherwise nil.

.names

Get the names of the Peers in this AddrBook.

Returns:

A Set containing Symbols corresponding to the names of the Peers in this AddrBook.

.peers

Get all the Peers in this AddrBook

Returns:

A Set containing the Peers in this AddrBook.

.onlinePeers

Get all the currently online Peers in this AddrBook

Returns:

A Set containing the Peers in this AddrBook which are currently online.

.me

Get the Peer representing the localhost.

Returns:

A Peer if me is defined, otherwise nil.

.addrs

Get all the addresses of the Peers in this AddrBook

Returns:

A Set containing the NetAddrs of the Peers in this AddrBook.

.includesAddr

Test to see if this AddrBook includes the supplied address, or an equivalent one in the case of the local computer (e.g. loopback address will match externally visible ones).

Arguments:

addr

A NetAddr to check for.

Returns:

A Boolean indicating if the the NetAddr matches one in this AddrBook.

.excluding

Get all Peers excluding the named Peer.

Arguments:

name

A Symbol corresponding to the name of the Peer to exclude.

Returns:

.others

Get all Peers excluding AddrBook.me.

Returns:

.asAddrBook

Returns this.