6#include <lo/lo_throw.h> 
   12#include <unordered_map> 
   14#if __cplusplus >= 201703L 
   17#include <initializer_list> 
   18#ifndef LO_USE_EXCEPTIONS 
   45#define LO_ADD_METHOD_RT(ht, argtypes, args, rt, r, r1, r2)             \ 
   46    template <typename H>                                               \ 
   47    Method add_method(const string_type path, const string_type types,  \ 
   48                      H&& h, rt* _unused=0)                             \ 
   50        std::string key(path.s() + "," + types.s());                    \ 
   51        _handlers[key].push_front(                                      \ 
   52            std::unique_ptr<handler>(new handler_type<r ht>(h)));       \ 
   53        lo_method m = _add_method(path, types,                          \ 
   54            [](const char *path, const char *types,                     \ 
   55               lo_arg **argv, int argc, lo_message msg,                 \ 
   58                r1 (*static_cast<handler_type<r ht>*>(data)) args;      \ 
   60            }, _handlers[key].front().get());                           \ 
   61        _handlers[key].front()->method = m;                             \ 
   65#define RT_INT(argtypes) \ 
   66    typename std::enable_if<std::is_same<decltype(h argtypes), int>::value, void>::type 
   67#define RT_VOID(argtypes) \ 
   68    typename std::enable_if<std::is_same<decltype(h argtypes), void>::value, void>::type 
   70#define LO_ADD_METHOD(ht, argtypes, args)                         \ 
   71    LO_ADD_METHOD_RT(ht, argtypes, args,                          \ 
   72                     RT_INT(argtypes), int, return,);             \ 
   73    LO_ADD_METHOD_RT(ht, argtypes, args,                          \ 
   74                     RT_VOID(argtypes), void, , return 0) 
   82        string_type(
const string_type& s) { _s = s._s; }
 
   83        string_type(
const char *s=0) { _s = s; }
 
   84        string_type(
const std::string &s) { _s = s.c_str(); }
 
   85#if __cplusplus >= 201703L 
   86        string_type(
const std::string_view& s) {
 
   87            if (s[s.length()]==0) _s = s.data();
 
   88            else { _p.reset(
new std::string(s)); _s = _p->c_str(); }
 
   91        operator const char*() 
const { 
return _s; }
 
   92        std::string s()
 const { 
return _s?_s:
""; }
 
   94        std::unique_ptr<std::string> _p;
 
   97    class num_string_type : 
public string_type {
 
   99        num_string_type(
const char *s) : string_type(s) {}
 
  100        num_string_type(
const std::string &s) : string_type(s) {}
 
  101#if __cplusplus >= 201703L 
  102        num_string_type(
const std::string_view& s) : string_type(s) {}
 
  104        num_string_type(
int n)
 
  105          {_p.reset(
new std::string(std::to_string(n))); _s = _p->c_str(); }
 
  137#ifdef LO_USE_EXCEPTIONS 
  140#define LO_CHECK_BEFORE if (!is_valid()) throw Invalid(); 
  141#define LO_CHECK_AFTER if (!is_valid()) throw Error(); 
  143#define LO_CHECK_BEFORE assert(is_valid()); 
  144#define LO_CHECK_AFTER 
  165        Address(
const string_type &host, 
const num_string_type &port,
 
  170        Address(
const string_type &url)
 
  174          { address = a; owned=_owned; LO_CHECK_AFTER; }
 
  180        void swap(
Address& b) 
throw () { std::swap(this->address, b.address); }
 
  182        bool is_valid()
 const { 
return address!=
nullptr; }
 
  187        void set_ttl(
int ttl)
 
  190        int send(
const string_type &path)
 const 
  191          { LO_CHECK_BEFORE; 
return lo_send(address, path, 
""); }
 
  196        int send(
const string_type &path, 
const string_type type, ...)
 const 
  202            std::string t = type.s() + 
"$$";
 
  210        int send(
lo_timetag ts, 
const string_type &path,
 
  211                 const string_type type, ...)
 const 
  217            std::string t = std::string(type) + 
"$$";
 
  227        int send(
const string_type &path, 
lo_message m)
 const 
  234                      const string_type type, ...) 
const;
 
  236        int send_from(
lo_server from, 
const string_type &path,
 
  237                      const string_type type, ...)
 const 
  243            std::string t = std::string(type) + 
"$$";
 
  252                      const string_type &path,
 
  253                      const string_type type, ...)
 const 
  259            std::string t = std::string(type) + 
"$$";
 
  277        int get_errno()
 const 
  280        std::string errstr()
 const 
  281          { LO_CHECK_BEFORE; 
auto s(
lo_address_errstr(address)); 
return std::string(s?s:
""); }
 
  283        std::string hostname()
 const 
  286        std::string port()
 const 
  292        std::string url()
 const 
  296            std::string result(s?s:
"");
 
  301        std::string iface()
 const 
  304        void set_iface(
const string_type &iface, 
const string_type &ip)
 
  307        int set_tcp_nodelay(
int enable)
 
 
  332            : message(m.message) { 
if (m.message)
 
  335        Message(
const string_type types, ...)
 
  342                std::string t(std::string(types)+
"$$");
 
  343                add_varargs(t.c_str(), q);
 
  353        void swap(
Message& m) 
throw () { std::swap(this->message, m.message); }
 
  355        bool is_valid()
 const { 
return message!=
nullptr; }
 
  357        int add(
const string_type types, ...)
 
  362            std::string t(std::string(types)+
"$$");
 
  363            int ret = add_varargs(t.c_str(), q);
 
  368        int add_varargs(
const string_type &types, va_list ap)
 
  371        int add_int32(int32_t a)
 
  374        int add_float(
float a)
 
  377        int add_string(
const string_type &a)
 
  383        int add_int64(int64_t a)
 
  389        int add_double(
double a)
 
  392        int add_symbol(
const string_type &a)
 
  398        int add_midi(uint8_t a[4])
 
  445        int add(uint8_t a[4])
 
  461        std::string types()
 const 
  471        size_t length(
const string_type &path)
 const 
  474        void *serialise(
const string_type &path, 
void *to, 
size_t *size)
 const 
  477        typedef std::pair<int, Message> maybe;
 
  480        maybe deserialise(
void *data, 
size_t size)
 
  483              return maybe(result, m); }
 
 
  506        template <
typename E>
 
  507        Server(
const num_string_type &port, E&& e)
 
  509              [](int num, const char *msg, const char *where){
 
  510                auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  511                if (h) (*h)(num, msg, where);
 
  515                lo_server_set_error_context(server,
 
  516                                            (_error_handler = std::unique_ptr<handler>(
 
  517                                                                                       new handler_error(e))).get());
 
 
  523        template <
typename E>
 
  524        Server(
const num_string_type &port, 
int proto, E&& e=0)
 
  526              [](int num, const char *msg, const char *where){
 
  527                auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  528                (*h)(num, msg, where);
 
  532                lo_server_set_error_context(server,
 
  533                                            (_error_handler = std::unique_ptr<handler>(
 
  534                                                                                       new handler_error(e))).get());
 
 
  541        template <
typename E>
 
  542        Server(
const string_type &group, 
const num_string_type &port,
 
  543               const string_type &iface=0, 
const string_type &ip=0, E&& e=0)
 
  544            : 
Server((!iface._s || !ip._s)
 
  546                           [](int num, const char *msg, const char *where){
 
  547                               auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  548                               (*h)(num, msg, where);
 
  551                           [](int num, const char *msg, const char *where){
 
  552                               auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  553                               (*h)(num, msg, where);
 
  557                lo_server_set_error_context(server,
 
  558                                            (_error_handler = std::unique_ptr<handler>(
 
  559                                                                                       new handler_error(e))).get());
 
 
  575        Server(
const string_type &group, 
const num_string_type &port,
 
  576               const string_type &iface=
"", 
const string_type &ip=
"", 
lo_err_handler err_h=0)
 
  577            : 
Server((iface._s || ip._s)
 
 
  587        bool is_valid()
 const { 
return server!=
nullptr; }
 
  595            { LO_CHECK_BEFORE; 
return _add_method(path, types, h, data); }
 
 
  602                       ((
char*)0, (
char*)0, (
lo_arg**)0, (
int)0),
 
  603                       (path, types, argv, argc) );
 
  608                       ((
char*)0, (
lo_arg**)0, (
int)0),
 
  609                       (types, argv, argc) );
 
  612                       (types, argv, argc, 
Message(msg)) );
 
  625        int del_method(
const string_type &path, 
const string_type &typespec)
 
  628            _handlers.erase(path.s() + 
"," + typespec.s());
 
  636          for (
auto &i : _handlers) {
 
  637            auto it = std::remove_if(i.second.begin(), i.second.end(),
 
  638                           [&](std::unique_ptr<handler>& h){return h->method == m;});
 
  639            i.second.erase(it, i.second.end());
 
  644        int dispatch_data(
void *data, 
size_t size)
 
  647        int wait(
int timeout)
 
  653        int recv(
int timeout)
 
  664        template <
typename S, 
typename E>
 
  665        int add_bundle_handlers(S&& s, E&& e)
 
  667            _bundle_handlers.reset(
new std::pair<handler_bundle_start,
 
  669                                       handler_bundle_start(s),
 
  670                                       handler_bundle_end(e)));
 
  674                    auto h = (std::pair<handler_bundle_start,
 
  675                                        handler_bundle_end>*) user_data;
 
  679                [](
void *user_data)->
int{
 
  680                    auto h = (std::pair<handler_bundle_start,
 
  681                                        handler_bundle_end>*) user_data;
 
  685                _bundle_handlers.get());
 
  688        int socket_fd()
 const 
  697        std::string url()
 const 
  701            std::string result(s?s:
"");
 
  706        int enable_queue(
int queue_enabled,
 
  707                         int dispatch_remaining=1)
 
  711                                            dispatch_remaining); }
 
  713        int events_pending()
 const 
  716        double next_event_delay()
 const 
  725        friend class ServerThread;
 
  727        struct handler { Method method; handler(Method m):method(m){} };
 
  728        template <
typename T>
 
  729        class handler_type : 
public handler, 
public std::function<T> {
 
  730          public: 
template<
typename H>handler_type(H&& h, Method m=0)
 
  731            : handler(m), std::function<T>(h) {}
 
  733        typedef handler_type<void(
int, 
const char *, 
const char *)> handler_error;
 
  734        typedef handler_type<void(
int, 
const std::string&, 
const std::string&)> handler_error_s;
 
  735        typedef handler_type<void(
lo_timetag)> handler_bundle_start;
 
  736        typedef handler_type<void()> handler_bundle_end;
 
  739        std::unordered_map<std::string,
 
  740            std::list<std::unique_ptr<handler>>> _handlers;
 
  741        std::unique_ptr<handler> _error_handler;
 
  742        std::unique_ptr<std::pair<handler_bundle_start,
 
  743                                  handler_bundle_end>> _bundle_handlers;
 
  745        virtual Method _add_method(
const char *path, 
const char *types,
 
 
  764        template <
typename E>
 
  769                    [](
int num, 
const char *msg, 
const char *where){
 
  770                    auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  773                    if (h) (*h)(num, msg, where);});
 
  776                    auto h = 
new handler_error(e);
 
  777                    _error_handler.reset(h);
 
  778                    lo_server_thread_set_error_context(server_thread, h);
 
  779                    lo_server_set_error_context(server,
 
  780                                            (_error_handler = std::unique_ptr<handler>(
 
  781                            new handler_error(e))).get());
 
  794        template <
typename E>
 
  795        ServerThread(
const num_string_type &port, 
int proto, E&& e)
 
  799                    [](
int num, 
const char *msg, 
const char *where){
 
  800                    auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  803                    if (h) (*h)(num, msg, where);});
 
  806                    auto h = 
new handler_error(e);
 
  807                    _error_handler.reset(h);
 
  808                    lo_server_thread_set_error_context(server_thread, h);
 
  809                    lo_server_set_error_context(server,
 
  810                                            (_error_handler = std::unique_ptr<handler>(
 
  811                            new handler_error(e))).get());
 
  816        ServerThread(
const string_type &group, 
const num_string_type &port,
 
  817                     const string_type &iface, 
const string_type &ip,
 
  819        { 
if (iface._s || ip._s)
 
  833        template <
typename I, 
typename C>
 
  834        auto set_callbacks(I&& init, C&& cleanup)
 
  835            -> 
typename std::enable_if<
 
  836                std::is_same<
decltype(init()), 
int>::value, 
void>::type
 
  840                    _cb_handlers.reset(
new handler_cb_pair(init, cleanup));
 
  843                           auto cb = (handler_cb_pair*)c;
 
  844                           return (cb->first)();
 
  847                           auto cb = (handler_cb_pair*)c;
 
  849                        }, _cb_handlers.get());
 
  853        template <
typename I, 
typename C>
 
  854        auto set_callbacks(I&& init, C&& cleanup)
 
  855            -> 
typename std::enable_if<
 
  856                std::is_same<
decltype(init()), 
void>::value, 
void>::type
 
  860                        (handler_cb_pair*)
new handler_cb_pair_void(init, cleanup));
 
  863                           auto cb = (handler_cb_pair_void*)c;
 
  864                           (cb->first)(); 
return 0;
 
  867                           auto cb = (handler_cb_pair_void*)c;
 
  869                        }, _cb_handlers.get());
 
  877            { 
return server_thread; }
 
  882        typedef std::pair<handler_type<int()>,handler_type<void()>> handler_cb_pair;
 
  883        typedef std::pair<handler_type<void()>,handler_type<void()>> handler_cb_pair_void;
 
  884        std::unique_ptr<handler_cb_pair> _cb_handlers;
 
  887        virtual Method _add_method(
const char *path, 
const char *types,
 
 
  900                                                   const string_type type, ...)
 const 
  906                std::string t = std::string(type) + 
"$$";
 
  927        Blob(int32_t size, 
const void *data=0)
 
  928            : blob(
lo_blob_new(size, data)) { LO_CHECK_AFTER; }
 
  930        template <
typename T>
 
  932            : blob(
lo_blob_new(t.size()*
sizeof(t[0]), &t[0])) { LO_CHECK_AFTER; }
 
  937        Blob& operator=(
Blob b) { b.swap(*
this); 
return *
this; }
 
  938        void swap(
Blob& b) 
throw () { std::swap(this->blob, b.blob); }
 
  940        bool is_valid()
 const { 
return blob!=
nullptr; }
 
  942        uint32_t datasize()
 const 
  945        void *dataptr()
 const 
  948        uint32_t size()
 const 
 
  963          : path(_path), msg(_msg) {}
 
 
  972        template <
typename T>
 
  977            ElementT(
const string_type _path, 
const Message& _msg)
 
  981            ElementT(
const T& _bundle)
 
  987        typedef ElementT<Bundle> Element;
 
 1011        Bundle(
const std::initializer_list<Element> &elements,
 
 1017            for (
auto const &e : elements) {
 
 1035        Bundle& operator=(
Bundle b) { b.swap(*
this); 
return *
this; }
 
 1036        void swap(
Bundle& b) 
throw () { std::swap(this->bundle, b.bundle); }
 
 1038        bool is_valid()
 const { 
return bundle!=
nullptr; }
 
 1040        int add(
const string_type &path, 
lo_message m)
 
 1046        size_t length()
 const 
 1049        unsigned int count()
 const 
 1052        lo_message get_message(
int index, 
const char **path=0)
 const 
 1055        Message get_message(
int index, std::string &path)
 const 
 1062        PathMsg get_message(
int index)
 const 
 1068        Bundle get_bundle(
int index)
 const 
 1071        Element get_element(
int index, 
const char **path=0)
 const 
 1078                    return Element(p, m);
 
 1090        void *serialise(
void *to, 
size_t *size)
 const 
 
 1107        return std::string(str);
 
 
Class representing an OSC destination address, proxy for lo_address.
Class representing an OSC blob, proxy for lo_blob.
Class representing an OSC bundle, proxy for lo_bundle.
Class representing an OSC message, proxy for lo_message.
Class representing an OSC method, proxy for lo_method.
Class representing a server thread, proxy for lo_server_thread.
Class representing a local OSC server, proxy for lo_server.
Server(const string_type &group, const num_string_type &port, const string_type &iface="", const string_type &ip="", lo_err_handler err_h=0)
Server(const num_string_type &port, lo_err_handler err_h=0)
Server(const num_string_type &port, int proto, lo_err_handler err_h=0)
Server(const num_string_type &port, int proto, E &&e=0)
Server(const num_string_type &port, E &&e)
LO_ADD_METHOD((const char *, lo_arg **, int),((char *) 0,(lo_arg **) 0,(int) 0),(types, argv, argc))
Server(const string_type &group, const num_string_type &port, const string_type &iface=0, const string_type &ip=0, E &&e=0)
LO_ADD_METHOD((const char *, const char *, lo_arg **, int),((char *) 0,(char *) 0,(lo_arg **) 0,(int) 0),(path, types, argv, argc))
Method add_method(const string_type &path, const string_type &types, lo_method_handler h, void *data) const
lo_element_type
An enumeration of bundle element types liblo can handle.
lo_address lo_address_new_from_url(const char *url)
Create a lo_address object from an OSC URL.
int lo_address_get_ttl(lo_address t)
Get the Time-to-Live value for a given target address.
int lo_address_errno(lo_address a)
Return the error number from the last failed lo_send() or lo_address_new() call.
void lo_address_free(lo_address t)
Free the memory used by the lo_address object.
void lo_blob_free(lo_blob b)
Free the memory taken by a blob.
uint32_t lo_blob_datasize(lo_blob b)
Return the amount of valid data in a lo_blob object.
void * lo_blob_dataptr(lo_blob b)
Return a pointer to the start of the blob data to allow contents to be changed.
void lo_address_set_ttl(lo_address t, int ttl)
Set the Time-to-Live value for a given target address.
lo_address lo_address_new_with_proto(int proto, const char *host, const char *port)
Declare an OSC destination, given IP address and port number, specifying protocol.
void lo_version(char *verstr, int verstr_size, int *major, int *minor, char *extra, int extra_size, int *lt_major, int *lt_minor, int *lt_bug)
Get information on the version of liblo current in use.
int lo_send(lo_address targ, const char *path, const char *type,...)
Send a OSC formatted message to the address specified.
#define LO_TT_IMMEDIATE
A timetag constant representing "now".
const char * lo_address_errstr(lo_address a)
Return the error string from the last failed lo_send() or lo_address_new() call.
lo_blob lo_blob_new(int32_t size, const void *data)
Create a new OSC blob type.
void * lo_message_serialise(lo_message m, const char *path, void *to, size_t *size)
Serialise the lo_message object to an area of memory and return a pointer to the serialised form....
int lo_message_add_timetag(lo_message m, lo_timetag a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_server_events_pending(lo_server s)
Return true if there are scheduled events (eg. from bundles) waiting to be dispatched by the server.
size_t lo_message_length(lo_message m, const char *path)
Return the length of a message in bytes.
const char * lo_address_get_hostname(lo_address a)
Return the hostname of a lo_address object.
int lo_server_add_bundle_handlers(lo_server s, lo_bundle_start_handler sh, lo_bundle_end_handler eh, void *user_data)
Add bundle notification handlers to the specified server.
lo_timetag lo_message_get_timestamp(lo_message m)
Returns the timestamp (lo_timetag *) of a bundled incoming message.
int lo_send_message(lo_address targ, const char *path, lo_message msg)
Send a lo_message object to target targ.
char * lo_server_get_url(lo_server s)
Return an OSC URL that can be used to contact the server.
lo_message lo_bundle_get_message(lo_bundle b, int index, const char **path)
Gets a message contained within a bundle.
int lo_message_add_false(lo_message m)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_bundle_add_message(lo_bundle b, const char *path, lo_message m)
Adds an OSC message to an existing bundle.
lo_message lo_message_new(void)
Create a new lo_message object.
lo_address lo_message_get_source(lo_message m)
Returns the source (lo_address) of an incoming message.
uint32_t lo_blobsize(lo_blob b)
A function to calculate the amount of OSC message space required by a lo_blob object.
void lo_bundle_free_messages(lo_bundle b)
Obsolete, use lo_bundle_free_recursive instead.
int lo_message_add_int64(lo_message m, int64_t a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
char * lo_message_get_types(lo_message m)
Return the message type tag string.
lo_message lo_message_deserialise(void *data, size_t size, int *result)
Deserialise a raw OSC message and return a new lo_message object. Opposite of lo_message_serialise().
lo_slip_encoding
Used with lo_address_set_stream_slip() to specify whether sent messages should be encoded with SLIP,...
lo_bundle lo_bundle_new(lo_timetag tt)
Create a new bundle object.
int lo_server_wait(lo_server s, int timeout)
Wait for an OSC message to be received.
int lo_server_enable_queue(lo_server s, int queue_enabled, int dispatch_remaining)
Toggle event queue. If queueing is enabled, timetagged messages that are sent in advance of the curre...
int lo_message_add_float(lo_message m, float a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
lo_server lo_server_new_with_proto(const char *port, int proto, lo_err_handler err_h)
Create a new server instance, specifying protocol.
int lo_message_add_infinitum(lo_message m)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_message_add_string(lo_message m, const char *a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_server_get_port(lo_server s)
Return the port number that the server has bound to.
lo_method lo_server_add_method(lo_server s, const char *path, const char *typespec, lo_method_handler h, const void *user_data)
Add an OSC method to the specifed server.
int lo_message_get_argc(lo_message m)
Return the message argument count.
lo_arg ** lo_message_get_argv(lo_message m)
Return the message arguments. Do not free the returned data.
int lo_address_set_iface(lo_address t, const char *iface, const char *ip)
Set the network interface to use for a given target address.
double lo_server_next_event_delay(lo_server s)
Return the time in seconds until the next scheduled event.
int lo_server_recv_noblock(lo_server s, int timeout)
Look for an OSC message waiting to be received.
lo_server lo_server_new(const char *port, lo_err_handler err_h)
Create a new server instance.
unsigned int lo_bundle_count(lo_bundle b)
Return the number of top-level elements in a bundle.
int lo_message_add_int32(lo_message m, int32_t a)
Append a data item and typechar of the specified type to a message.
int lo_address_set_stream_slip(lo_address t, lo_slip_encoding encoding)
Set outgoing stream connections (e.g., TCP) to be transmitted using the SLIP packetizing protocol.
lo_server lo_server_new_multicast(const char *group, const char *port, lo_err_handler err_h)
Create a new server instance, and join a UDP multicast group.
lo_element_type lo_bundle_get_type(lo_bundle b, int index)
Gets the element type contained within a bundle.
lo_message lo_message_clone(lo_message m)
Create a new lo_message object by cloning an already existing one.
void lo_bundle_free_recursive(lo_bundle b)
Frees the memory taken by a bundle object and its messages and nested bundles recursively.
int lo_message_add_symbol(lo_message m, const char *a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
const char * lo_address_get_iface(lo_address t)
Get the name of the network interface assigned to an OSC address.
void lo_message_free(lo_message m)
Free memory allocated by lo_message_new() and any subsequent lo_message_add_int32 lo_message_add*() c...
int lo_message_add_varargs(lo_message m, const char *types, va_list ap)
Append a varargs list to a message.
int lo_send_message_from(lo_address targ, lo_server serv, const char *path, lo_message msg)
Send a lo_message object to target targ from address of serv.
int lo_address_set_tcp_nodelay(lo_address t, int enable)
Set the TCP_NODELAY flag on outgoing TCP connections.
int lo_message_add_true(lo_message m)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_server_dispatch_data(lo_server s, void *data, size_t size)
Dispatch a raw block of memory containing an OSC message.
size_t lo_bundle_length(lo_bundle b)
Return the length of a bundle in bytes.
int lo_address_get_protocol(lo_address a)
Return the protocol of a lo_address object.
int lo_message_add_midi(lo_message m, uint8_t a[4])
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
lo_bundle lo_bundle_get_bundle(lo_bundle b, int index)
Gets a nested bundle contained within a bundle.
int lo_message_add_char(lo_message m, char a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_server_get_protocol(lo_server s)
Return the protocol that the server is using.
int lo_send_bundle_from(lo_address targ, lo_server serv, lo_bundle b)
Send a lo_bundle object to address targ from address of serv.
int lo_server_del_lo_method(lo_server s, lo_method m)
Delete a specific OSC method from the specified server.
int lo_message_add_nil(lo_message m)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
int lo_message_add_blob(lo_message m, lo_blob a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
const char * lo_address_get_port(lo_address a)
Return the port/service name of a lo_address object.
char * lo_address_get_url(lo_address a)
Return a URL representing an OSC address.
int lo_send_bundle(lo_address targ, lo_bundle b)
Send a lo_bundle object to address targ.
int lo_bundle_add_bundle(lo_bundle b, lo_bundle n)
Adds an OSC bundle to an existing bundle.
void lo_server_free(lo_server s)
Free up memory used by the lo_server object.
void lo_timetag_now(lo_timetag *t)
Return a timetag for the current time.
int lo_message_add_double(lo_message m, double a)
Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for de...
lo_server lo_server_new_multicast_iface(const char *group, const char *port, const char *iface, const char *ip, lo_err_handler err_h)
Create a new server instance, and join a UDP multicast group, optionally specifying which network int...
int lo_server_get_socket_fd(lo_server s)
Return the file descriptor of the server socket.
void lo_message_incref(lo_message m)
Add one to a message's reference count.
int lo_server_recv(lo_server s)
Block, waiting for an OSC message to be received.
lo_timetag lo_bundle_get_timestamp(lo_bundle b)
Get the timestamp associated with a bundle.
void lo_bundle_incref(lo_bundle b)
Add one to a bundle's reference count.
void * lo_bundle_serialise(lo_bundle b, void *to, size_t *size)
Serialise the bundle object to an area of memory and return a pointer to the serialised form.
void lo_server_del_method(lo_server s, const char *path, const char *typespec)
Delete an OSC method from the specified server.
void lo_message_pp(lo_message m)
Pretty-print a lo_message object.
void lo_bundle_pp(lo_bundle b)
Pretty-print a lo_bundle object.
lo_timetag immediate()
Return the OSC timetag representing "immediately".
lo_timetag now()
Return the current time in lo_timetag format.
std::string version()
Return the library version as an std::string.
int lo_server_thread_stop(lo_server_thread st)
Stop the server thread.
lo_server_thread lo_server_thread_new_multicast(const char *group, const char *port, lo_err_handler err_h)
Create a new server thread to handle incoming OSC messages, and join a UDP multicast group.
int lo_server_thread_start(lo_server_thread st)
Start the server thread.
lo_server_thread lo_server_thread_new_with_proto(const char *port, int proto, lo_err_handler err_h)
Create a new server thread to handle incoming OSC messages, specifying protocol.
void lo_server_thread_set_callbacks(lo_server_thread st, lo_server_thread_init_callback init, lo_server_thread_cleanup_callback cleanup, void *user_data)
Set an init and/or a cleanup function to the specifed server thread.
lo_server lo_server_thread_get_server(lo_server_thread st)
Return the lo_server for a lo_server_thread.
lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_h)
Create a new server thread to handle incoming OSC messages.
lo_server_thread lo_server_thread_new_multicast_iface(const char *group, const char *port, const char *iface, const char *ip, lo_err_handler err_h)
Create a new server thread instance, and join a UDP multicast group, optionally specifying which netw...
void lo_server_thread_free(lo_server_thread st)
Free memory taken by a server thread.
lo_method lo_server_thread_add_method(lo_server_thread st, const char *path, const char *typespec, lo_method_handler h, const void *user_data)
Add an OSC method to the specifed server thread.
struct lo_server_ * lo_server
An object representing an instance of an OSC server.
int(* lo_bundle_start_handler)(lo_timetag time, void *user_data)
A callback function to receive notification of a bundle being dispatched by the server or server thre...
struct lo_address_ * lo_address
A reference to an OSC service.
struct lo_message_ * lo_message
A low-level object used to represent messages passed over OSC.
int(* lo_method_handler)(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data)
A callback function to receive notification of matching message arriving in the server or server thre...
struct lo_blob_ * lo_blob
A object to store an opaque binary data object.
void(* lo_err_handler)(int num, const char *msg, const char *where)
A callback function to receive notification of an error in a server or server thread.
int(* lo_bundle_end_handler)(void *user_data)
A callback function to receive notification of a bundle dispatch being completed by the server or ser...
struct lo_server_thread_ * lo_server_thread
An object representing a thread containing an OSC server.
struct lo_bundle_ * lo_bundle
A low-level object used to represent bundles of messages passed over OSC.
struct lo_method_ * lo_method
An object representing an method on a server.
Class representing an OSC path (std::string) and lo::Message pair.
Union used to read values from incoming messages.