TuningFork.Osc.Client (TuningFork v0.1.11)

Copy Markdown View Source

A UDP socket for sending TuningFork.Osc messages, and reading them back.

{:ok, client} = Osc.Client.start_link(host: "127.0.0.1", port: 57_120)
Osc.Client.send(client, "/play", [60, 0.8])

Summary

Functions

Send several messages as one bundle under the time tag at.

Returns a specification to start this module under a supervisor.

Send bytes already encoded.

Point the client somewhere else.

Open a socket.

Where this client is sending, as {host, port}.

Types

t()

@type t() :: GenServer.server()

Functions

bundle(client, messages, at \\ :now)

@spec bundle(t(), [{String.t(), [term()]}], :now | DateTime.t()) :: :ok

Send several messages as one bundle under the time tag at.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

packet(client, bytes)

@spec packet(t(), binary()) :: :ok

Send bytes already encoded.

point(client, host, port)

@spec point(t(), term(), pos_integer()) :: :ok

Point the client somewhere else.

send(client, address, args \\ [])

@spec send(t(), String.t(), [term()]) :: :ok

Send one message.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Open a socket.

With :listen, every message that arrives is sent to :owner as {:osc, address, args, {from_host, from_port}}; a packet that does not decode as a message is dropped.

Options

  • :host — where to send, a charlist, binary or tuple. Default "127.0.0.1"
  • :port — which port to send to. Default 57120
  • :listen — bind this port and read as well as write. Default none
  • :owner — who to send what arrives to. Default whoever called
  • :name — register the client under a name

to(client)

@spec to(t()) :: {term(), pos_integer()}

Where this client is sending, as {host, port}.