hosc-0.20: Haskell Open Sound Control

Safe Haskell | Safe-Inferred
Language | Haskell2010

Sound.Osc.Transport.Fd

Contents

- Send
- Receive
- Wait

Description

An abstract transport layer with implementations for `Udp` and `Tcp` transport.

Synopsis

- class Transport t where
  - sendPacket :: t -> Packet -> IO ()
  - recvPacket :: t -> IO Packet
  - close :: t -> IO ()
- withTransport :: Transport t => IO t -> (t -> IO a) -> IO a
- sendMessage :: Transport t => t -> Message -> IO ()
- sendBundle :: Transport t => t -> Bundle -> IO ()
- recvBundle :: Transport t => t -> IO Bundle
- recvMessage :: Transport t => t -> IO (Maybe Message)
- recvMessages :: Transport t => t -> IO [Message]
- waitUntil :: Transport t => t -> (Packet -> Bool) -> IO Packet
- waitFor :: Transport t => t -> (Packet -> Maybe a) -> IO a
- waitImmediate :: Transport t => t -> IO Packet
- waitMessage :: Transport t => t -> IO Message
- waitAddress :: Transport t => t -> Address_Pattern -> IO Packet
- waitReply :: Transport t => t -> Address_Pattern -> IO Message
- waitDatum :: Transport t => t -> Address_Pattern -> IO [Datum]

# Documentation

class Transport t where Source #

Abstract over the underlying transport protocol.

Methods

sendPacket :: t -> Packet -> IO () Source #

Encode and send an Osc packet.

recvPacket :: t -> IO Packet Source #

Receive and decode an Osc packet.

close :: t -> IO () Source #

Close an existing connection.

#### Instances

Instances details

Transport Tcp Source # | `Tcp` is an instance of `Transport`.
Instance details Defined in Sound.Osc.Transport.Fd.Tcp Methods sendPacket :: Tcp -> Packet -> IO () Source # recvPacket :: Tcp -> IO Packet Source # close :: Tcp -> IO () Source #
Transport Udp Source # | `Udp` is an instance of `Transport`.
Instance details Defined in Sound.Osc.Transport.Fd.Udp Methods sendPacket :: Udp -> Packet -> IO () Source # recvPacket :: Udp -> IO Packet Source # close :: Udp -> IO () Source #

withTransport :: Transport t => IO t -> (t -> IO a) -> IO a Source #

Bracket Osc communication.

# Send

sendMessage :: Transport t => t -> Message -> IO () Source #

`sendPacket` of `Packet_Message`.

sendBundle :: Transport t => t -> Bundle -> IO () Source #

`sendPacket` of `Packet_Bundle`.

# Receive

recvBundle :: Transport t => t -> IO Bundle Source #

Variant of `recvPacket` that runs `packet_to_bundle`.

recvMessage :: Transport t => t -> IO (Maybe Message) Source #

Variant of `recvPacket` that runs `packet_to_message`.

recvMessages :: Transport t => t -> IO [Message] Source #

Variant of `recvPacket` that runs `packetMessages`.

# Wait

waitUntil :: Transport t => t -> (Packet -> Bool) -> IO Packet Source #

Wait for a `Packet` where the supplied predicate is `True`, discarding intervening packets.

waitFor :: Transport t => t -> (Packet -> Maybe a) -> IO a Source #

Wait for a `Packet` where the supplied function does not give `Nothing`, discarding intervening packets.

waitImmediate :: Transport t => t -> IO Packet Source #

`waitUntil` `packet_is_immediate`.

waitMessage :: Transport t => t -> IO Message Source #

`waitFor` `packet_to_message`, ie. an incoming `Message` or immediate mode `Bundle` with one element.

waitAddress :: Transport t => t -> Address_Pattern -> IO Packet Source #

A `waitFor` for variant using `packet_has_address` to match on the `Address_Pattern` of incoming `Packets`.

waitReply :: Transport t => t -> Address_Pattern -> IO Message Source #

Variant on `waitAddress` that returns matching `Message`.

waitDatum :: Transport t => t -> Address_Pattern -> IO [Datum] Source #

Variant of `waitReply` that runs `messageDatum`.