Go to the documentation of this file.
    6 #include <lo/lo_throw.h> 
   12 #include <unordered_map> 
   15 #include <initializer_list> 
   40 #define LO_ADD_METHOD_RT(ht, argtypes, args, rt, r, r1, r2)             \ 
   41     template <typename H>                                               \ 
   42     Method add_method(const string_type path, const string_type types,  \ 
   43                       H&& h, rt* _unused=0)                             \ 
   45         std::string key(path.s() + "," + types.s());                    \ 
   46         _handlers[key].push_front(                                      \ 
   47             std::unique_ptr<handler>(new handler_type<r ht>(h)));       \ 
   48         lo_method m = _add_method(path, types,                          \ 
   49             [](const char *path, const char *types,                     \ 
   50                lo_arg **argv, int argc, void *msg,                      \ 
   53                 r1 (*static_cast<handler_type<r ht>*>(data)) args;      \ 
   55             }, _handlers[key].front().get());                           \ 
   56         _handlers[key].front()->method = m;                             \ 
   60 #define RT_INT(argtypes) \ 
   61     typename std::enable_if<std::is_same<decltype(h argtypes), int>::value, void>::type 
   62 #define RT_VOID(argtypes) \ 
   63     typename std::enable_if<std::is_same<decltype(h argtypes), void>::value, void>::type 
   65 #define LO_ADD_METHOD(ht, argtypes, args)                         \ 
   66     LO_ADD_METHOD_RT(ht, argtypes, args,                          \ 
   67                      RT_INT(argtypes), int, return,);             \ 
   68     LO_ADD_METHOD_RT(ht, argtypes, args,                          \ 
   69                      RT_VOID(argtypes), void, , return 0) 
   77         string_type(
const char *s=0) { _s = s; }
 
   78         string_type(
const std::string &s) { _s = s.c_str(); }
 
   79         operator const char*() 
const { 
return _s; }
 
   80         std::string s()
 const { 
return _s?_s:
""; }
 
   84     class num_string_type : 
public string_type {
 
   86       num_string_type(
const char *s) : string_type(s) {}
 
   87       num_string_type(
const std::string &s) : string_type(s) {}
 
   88         num_string_type(
int n) { std::ostringstream ss; ss << n;
 
   89             _p.reset(
new std::string(ss.str())); _s = _p->c_str(); }
 
   90         std::unique_ptr<std::string> _p;
 
  122 #ifdef LO_USE_EXCEPTIONS 
  125 #define LO_CHECK_BEFORE if (!is_valid()) throw Invalid(); 
  126 #define LO_CHECK_AFTER if (!is_valid()) throw Error(); 
  129 #define LO_CHECK_BEFORE assert(is_valid()); 
  130 #define LO_CHECK_AFTER 
  151         Address(
const string_type &host, 
const num_string_type &port,
 
  156         Address(
const string_type &url)
 
  160           { address = a; owned=_owned; LO_CHECK_AFTER; }
 
  166         void swap(
Address& b) 
throw () { std::swap(this->address, b.address); }
 
  168         bool is_valid()
 const { 
return address!=
nullptr; }
 
  173         void set_ttl(
int ttl)
 
  176         int send(
const string_type &path)
 const 
  177           { LO_CHECK_BEFORE; 
return lo_send(address, path, 
""); }
 
  182         int send(
const string_type &path, 
const string_type type, ...)
 const 
  188             std::string t = type.s() + 
"$$";
 
  196         int send(
lo_timetag ts, 
const string_type &path,
 
  197                  const string_type type, ...)
 const 
  203             std::string t = std::string(type) + 
"$$";
 
  213         int send(
const string_type &path, 
lo_message m)
 const 
  220                       const string_type type, ...) 
const;
 
  222         int send_from(
lo_server from, 
const string_type &path,
 
  223                       const string_type type, ...)
 const 
  229             std::string t = std::string(type) + 
"$$";
 
  238                       const string_type &path,
 
  239                       const string_type type, ...)
 const 
  245             std::string t = std::string(type) + 
"$$";
 
  263         int get_errno()
 const 
  266         std::string errstr()
 const 
  267           { LO_CHECK_BEFORE; 
auto s(
lo_address_errstr(address)); 
return std::string(s?s:
""); }
 
  269         std::string hostname()
 const 
  272         std::string port()
 const 
  278         std::string url()
 const 
  282             std::string result(s?s:
"");
 
  287         std::string iface()
 const 
  290         void set_iface(
const string_type &iface, 
const string_type &ip)
 
  293         int set_tcp_nodelay(
int enable)
 
  296         int set_stream_slip(
int enable)
 
  318             : message(m.message) { 
if (m.message)
 
  321         Message(
const string_type types, ...)
 
  328                 std::string t(std::string(types)+
"$$");
 
  329                 add_varargs(t.c_str(), q);
 
  339         void swap(
Message& m) 
throw () { std::swap(this->message, m.message); }
 
  341         bool is_valid()
 const { 
return message!=
nullptr; }
 
  343         int add(
const string_type types, ...)
 
  348             std::string t(std::string(types)+
"$$");
 
  349             int ret = add_varargs(t.c_str(), q);
 
  354         int add_varargs(
const string_type &types, va_list ap)
 
  357         int add_int32(int32_t a)
 
  360         int add_float(
float a)
 
  363         int add_string(
const string_type &a)
 
  369         int add_int64(int64_t a)
 
  375         int add_double(
double a)
 
  378         int add_symbol(
const string_type &a)
 
  384         int add_midi(uint8_t a[4])
 
  431         int add(uint8_t a[4])
 
  447         std::string types()
 const 
  457         size_t length(
const string_type &path)
 const 
  460         void *serialise(
const string_type &path, 
void *to, 
size_t *size)
 const 
  463         typedef std::pair<int, Message> maybe;
 
  466         maybe deserialise(
void *data, 
size_t size)
 
  469               return maybe(result, m); }
 
  492         template <
typename E>
 
  493         Server(
const num_string_type &port, E&& e)
 
  495               [](int num, const char *msg, const char *where){
 
  496                 auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  497                 if (h) (*h)(num, msg, where);
 
  501                 lo_server_set_error_context(server,
 
  502                                             (_error_handler = std::unique_ptr<handler>(
 
  503                                                                                        new handler_error(e))).get());
 
  509         template <
typename E>
 
  510         Server(
const num_string_type &port, 
int proto, E&& e=0)
 
  512               [](int num, const char *msg, const char *where){
 
  513                 auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  514                 (*h)(num, msg, where);
 
  518                 lo_server_set_error_context(server,
 
  519                                             (_error_handler = std::unique_ptr<handler>(
 
  520                                                                                        new handler_error(e))).get());
 
  527         template <
typename E>
 
  528         Server(
const string_type &group, 
const num_string_type &port,
 
  529                const string_type &iface=0, 
const string_type &ip=0, E&& e=0)
 
  530             : 
Server((!iface._s || !ip._s)
 
  532                            [](int num, const char *msg, const char *where){
 
  533                                auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  534                                (*h)(num, msg, where);
 
  537                            [](
int num, 
const char *msg, 
const char *where){
 
  538                                auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  539                                (*h)(num, msg, where);
 
  543                 lo_server_set_error_context(server,
 
  544                                             (_error_handler = std::unique_ptr<handler>(
 
  545                                                                                        new handler_error(e))).get());
 
  561         Server(
const string_type &group, 
const num_string_type &port,
 
  562                const string_type &iface=
"", 
const string_type &ip=
"", 
lo_err_handler err_h=0)
 
  563             : 
Server((iface._s || ip._s)
 
  573         bool is_valid()
 const { 
return server!=
nullptr; }
 
  581             { LO_CHECK_BEFORE; 
return _add_method(path, types, h, data); }
 
  588                        ((
char*)0, (
char*)0, (
lo_arg**)0, (
int)0),
 
  589                        (path, types, argv, argc) );
 
  594                        ((
char*)0, (
lo_arg**)0, (
int)0),
 
  595                        (types, argv, argc) );
 
  598                        (types, argv, argc, 
Message(msg)) );
 
  611         int del_method(
const string_type &path, 
const string_type &typespec)
 
  614             _handlers.erase(path.s() + 
"," + typespec.s());
 
  622           for (
auto &i : _handlers) {
 
  623             std::remove_if(i.second.begin(), i.second.end(),
 
  624                            [&](std::unique_ptr<handler>& h){return h->method == m;});
 
  629         int dispatch_data(
void *data, 
size_t size)
 
  632         int wait(
int timeout)
 
  638         int recv(
int timeout)
 
  649         template <
typename S, 
typename E>
 
  650         int add_bundle_handlers(S&& s, E&& e)
 
  652             _bundle_handlers.reset(
new std::pair<handler_bundle_start,
 
  654                                        handler_bundle_start(s),
 
  655                                        handler_bundle_end(e)));
 
  659                     auto h = (std::pair<handler_bundle_start,
 
  660                                         handler_bundle_end>*) user_data;
 
  664                 [](
void *user_data)->
int{
 
  665                     auto h = (std::pair<handler_bundle_start,
 
  666                                         handler_bundle_end>*) user_data;
 
  670                 _bundle_handlers.get());
 
  673         int socket_fd()
 const 
  682         std::string url()
 const 
  686             std::string result(s?s:
"");
 
  691         int enable_queue(
int queue_enabled,
 
  692                          int dispatch_remaining=1)
 
  696                                             dispatch_remaining); }
 
  698         int events_pending()
 const 
  701         double next_event_delay()
 const 
  710         friend class ServerThread;
 
  712         struct handler { Method method; handler(Method m):method(m){} };
 
  713         template <
typename T>
 
  714         class handler_type : 
public handler, 
public std::function<T> {
 
  715           public: 
template<
typename H>handler_type(H&& h, Method m=0)
 
  716             : handler(m), std::function<T>(h) {}
 
  718         typedef handler_type<void(
int, 
const char *, 
const char *)> handler_error;
 
  719         typedef handler_type<void(
int, 
const std::string&, 
const std::string&)> handler_error_s;
 
  720         typedef handler_type<void(
lo_timetag)> handler_bundle_start;
 
  721         typedef handler_type<void()> handler_bundle_end;
 
  724         std::unordered_map<std::string,
 
  725             std::list<std::unique_ptr<handler>>> _handlers;
 
  726         std::unique_ptr<handler> _error_handler;
 
  727         std::unique_ptr<std::pair<handler_bundle_start,
 
  728                                   handler_bundle_end>> _bundle_handlers;
 
  730         virtual Method _add_method(
const char *path, 
const char *types,
 
  748         template <
typename E>
 
  753                     [](
int num, 
const char *msg, 
const char *where){
 
  754                     auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  757                     if (h) (*h)(num, msg, where);});
 
  760                     auto h = 
new handler_error(e);
 
  761                     _error_handler.reset(h);
 
  762                     lo_server_thread_set_error_context(server_thread, h);
 
  763                     lo_server_set_error_context(server,
 
  764                                             (_error_handler = std::unique_ptr<handler>(
 
  765                             new handler_error(e))).get());
 
  778         template <
typename E>
 
  779         ServerThread(
const num_string_type &port, 
int proto, E&& e)
 
  783                     [](
int num, 
const char *msg, 
const char *where){
 
  784                     auto h = 
static_cast<handler_error*
>(lo_error_get_context());
 
  787                     if (h) (*h)(num, msg, where);});
 
  790                     auto h = 
new handler_error(e);
 
  791                     _error_handler.reset(h);
 
  792                     lo_server_thread_set_error_context(server_thread, h);
 
  793                     lo_server_set_error_context(server,
 
  794                                             (_error_handler = std::unique_ptr<handler>(
 
  795                             new handler_error(e))).get());
 
  800         ServerThread(
const string_type &group, 
const num_string_type &port,
 
  801                      const string_type &iface, 
const string_type &ip,
 
  803         { 
if (iface._s || ip._s)
 
  817         template <
typename I, 
typename C>
 
  818         auto set_callbacks(I&& init, C&& cleanup)
 
  819             -> 
typename std::enable_if<
 
  820                 std::is_same<decltype(init()), 
int>::value, 
void>::type
 
  824                     _cb_handlers.reset(
new handler_cb_pair(init, cleanup));
 
  827                            auto cb = (handler_cb_pair*)c;
 
  828                            return (cb->first)();
 
  831                            auto cb = (handler_cb_pair*)c;
 
  833                         }, _cb_handlers.get());
 
  837         template <
typename I, 
typename C>
 
  838         auto set_callbacks(I&& init, C&& cleanup)
 
  839             -> 
typename std::enable_if<
 
  840                 std::is_same<decltype(init()), 
void>::value, 
void>::type
 
  844                         (handler_cb_pair*)
new handler_cb_pair_void(init, cleanup));
 
  847                            auto cb = (handler_cb_pair_void*)c;
 
  848                            (cb->first)(); 
return 0;
 
  851                            auto cb = (handler_cb_pair_void*)c;
 
  853                         }, _cb_handlers.get());
 
  861             { 
return server_thread; }
 
  866         typedef std::pair<handler_type<int()>,handler_type<void()>> handler_cb_pair;
 
  867         typedef std::pair<handler_type<void()>,handler_type<void()>> handler_cb_pair_void;
 
  868         std::unique_ptr<handler_cb_pair> _cb_handlers;
 
  871         virtual Method _add_method(
const char *path, 
const char *types,
 
  884                                                    const string_type type, ...)
 const 
  890                 std::string t = std::string(type) + 
"$$";
 
  911         Blob(int32_t size, 
const void *data=0)
 
  912             : blob(
lo_blob_new(size, data)) { LO_CHECK_AFTER; }
 
  914         template <
typename T>
 
  916             : blob(
lo_blob_new(t.size()*
sizeof(t[0]), &t[0])) { LO_CHECK_AFTER; }
 
  921         Blob& operator=(
Blob b) { b.swap(*
this); 
return *
this; }
 
  922         void swap(
Blob& b) 
throw () { std::swap(this->blob, b.blob); }
 
  924         bool is_valid()
 const { 
return blob!=
nullptr; }
 
  926         uint32_t datasize()
 const 
  929         void *dataptr()
 const 
  932         uint32_t size()
 const 
  947           : path(_path), msg(_msg) {}
 
  956         template <
typename T>
 
  961             ElementT(
const string_type _path, 
const Message& _msg)
 
  965             ElementT(
const T& _bundle)
 
  971         typedef ElementT<Bundle> Element;
 
  995         Bundle(
const std::initializer_list<Element> &elements,
 
 1001             for (
auto const &e : elements) {
 
 1019         Bundle& operator=(
Bundle b) { b.swap(*
this); 
return *
this; }
 
 1020         void swap(
Bundle& b) 
throw () { std::swap(this->bundle, b.bundle); }
 
 1022         bool is_valid()
 const { 
return bundle!=
nullptr; }
 
 1024         int add(
const string_type &path, 
lo_message m)
 
 1030         size_t length()
 const 
 1033         unsigned int count()
 const 
 1036         lo_message get_message(
int index, 
const char **path=0)
 const 
 1039         Message get_message(
int index, std::string &path)
 const 
 1046         PathMsg get_message(
int index)
 const 
 1052         Bundle get_bundle(
int index)
 const 
 1055         Element get_element(
int index, 
const char **path=0)
 const 
 1062                     return Element(p, m);
 
 1074         void *serialise(
void *to, 
size_t *size)
 const 
 1091         return std::string(str);
 
 1103 #endif // _LO_CPP_H_ 
  
lo_blob lo_blob_new(int32_t size, const void *data)
Create a new OSC blob type.
char * lo_message_get_types(lo_message m)
Return the message type tag string.
uint32_t lo_blob_datasize(lo_blob b)
Return the amount of valid data in a lo_blob object.
void lo_message_pp(lo_message m)
Pretty-print a lo_message object.
void lo_server_thread_free(lo_server_thread st)
Free memory taken by a server thread.
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_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...
int lo_message_add_varargs(lo_message m, const char *types, va_list ap)
Append a varargs list to a message.
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...
lo_address lo_address_new_from_url(const char *url)
Create a lo_address object from an OSC URL.
Class representing an OSC method, proxy for lo_method.
char * lo_address_get_url(lo_address a)
Return a URL representing an OSC address.
void lo_address_free(lo_address t)
Free the memory used by the lo_address object.
Class representing an OSC destination address, proxy for lo_address.
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_bundle lo_bundle_get_bundle(lo_bundle b, int index)
Gets a nested bundle contained within a bundle.
const char * lo_address_get_port(lo_address a)
Return the port/service name of a lo_address object.
std::string version()
Return the library version as an std::string.
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_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...
Server(const num_string_type &port, int proto, lo_err_handler err_h=0)
void * lo_server
An object representing an instance of an OSC server.
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...
int lo_address_set_tcp_nodelay(lo_address t, int enable)
Set the TCP_NODELAY flag on outgoing TCP connections.
lo_server lo_server_new_with_proto(const char *port, int proto, lo_err_handler err_h)
Create a new server instance, specifying protocol.
uint32_t lo_blobsize(lo_blob b)
A function to calculate the amount of OSC message space required by a lo_blob object.
int lo_server_get_port(lo_server s)
Return the port number that the server has bound to.
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_server lo_server_thread_get_server(lo_server_thread st)
Return the lo_server for a lo_server_thread.
size_t lo_bundle_length(lo_bundle b)
Return the length of a bundle in bytes.
lo_server lo_server_new(const char *port, lo_err_handler err_h)
Create a new server instance.
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_protocol(lo_server s)
Return the protocol that the server is using.
size_t lo_message_length(lo_message m, const char *path)
Return the length of a message in bytes.
Class representing an OSC message, proxy for lo_message.
int lo_bundle_add_message(lo_bundle b, const char *path, lo_message m)
Adds an OSC message to an existing bundle.
int lo_server_recv(lo_server s)
Block, waiting for an OSC message to be received.
void lo_bundle_free_messages(lo_bundle b)
Obsolete, use lo_bundle_free_recursive instead.
const char * lo_address_get_iface(lo_address t)
Get the name of the network interface assigned to an OSC address.
int lo_server_del_lo_method(lo_server s, lo_method m)
Delete a specific OSC method from the specified server.
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.
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().
void lo_message_incref(lo_message m)
Add one to a message's reference count.
void * lo_method
An object representing an method on a server.
lo_message lo_bundle_get_message(lo_bundle b, int index, const char **path)
Gets a message contained within a bundle.
lo_address lo_message_get_source(lo_message m)
Returns the source (lo_address) of an incoming message.
lo_timetag lo_message_get_timestamp(lo_message m)
Returns the timestamp (lo_timetag *) of a bundled incoming message.
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.
lo_timetag lo_bundle_get_timestamp(lo_bundle b)
Get the timestamp associated with a bundle.
double lo_server_next_event_delay(lo_server s)
Return the time in seconds until the next scheduled event.
void * lo_blob
A object to store an opaque binary data object.
void lo_bundle_pp(lo_bundle b)
Pretty-print a lo_bundle object.
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.
void * lo_blob_dataptr(lo_blob b)
Return a pointer to the start of the blob data to allow contents to be changed.
unsigned int lo_bundle_count(lo_bundle b)
Return the number of top-level elements in a bundle.
Server(const string_type &group, const num_string_type &port, const string_type &iface=0, const string_type &ip=0, E &&e=0)
void * lo_server_thread
An object representing a thread containing an OSC server.
lo_timetag now()
Return the current time in lo_timetag format.
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...
Server(const string_type &group, const num_string_type &port, const string_type &iface="", const string_type &ip="", lo_err_handler err_h=0)
void lo_bundle_incref(lo_bundle b)
Add one to a bundle's reference count.
int lo_address_errno(lo_address a)
Return the error number from the last failed lo_send() or lo_address_new() call.
Class representing an OSC path (std::string) and lo::Message pair.
lo_timetag immediate()
Return the OSC timetag representing "immediately".
lo_message lo_message_new(void)
Create a new lo_message object.
int lo_server_thread_start(lo_server_thread st)
Start the server thread.
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...
Server(const num_string_type &port, int proto, E &&e=0)
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...
int lo_address_get_protocol(lo_address a)
Return the protocol of a lo_address object.
Class representing an OSC bundle, proxy for lo_bundle.
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.
int lo_send_message(lo_address targ, const char *path, lo_message msg)
Send a lo_message object to target targ.
void lo_timetag_now(lo_timetag *t)
Return a timetag for the current time.
void * lo_bundle
A low-level object used to represent bundles of messages passed over OSC.
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.
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_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...
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....
#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.
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...
int lo_send(lo_address targ, const char *path, const char *type,...)
Send a OSC formatted message to the address specified.
Union used to read values from incoming messages.
Class representing an OSC blob, proxy for lo_blob.
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...
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.
lo_arg ** lo_message_get_argv(lo_message m)
Return the message arguments. Do not free the returned data.
Method add_method(const string_type &path, const string_type &types, lo_method_handler h, void *data) const
LO_ADD_METHOD((const char *, const char *, lo_arg **, int),((char *) 0,(char *) 0,(lo_arg **) 0,(int) 0),(path, types, argv, argc))
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.
Class representing a server thread, proxy for lo_server_thread.
char * lo_server_get_url(lo_server s)
Return an OSC URL that can be used to contact the server.
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.
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.
lo_element_type
An enumeration of bundle element types liblo can handle.
const char * lo_address_get_hostname(lo_address a)
Return the hostname of a lo_address object.
int lo_message_get_argc(lo_message m)
Return the message argument count.
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.
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...
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...
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.
void * lo_address
A reference to an OSC service.
lo_element_type lo_bundle_get_type(lo_bundle b, int index)
Gets the element type contained within a bundle.
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_thread_stop(lo_server_thread st)
Stop the server thread.
Server(const num_string_type &port, E &&e)
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...
lo_message lo_message_clone(lo_message m)
Create a new lo_message object by cloning an already existing one.
Class representing a local OSC server, proxy for lo_server.
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.
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...
void lo_server_del_method(lo_server s, const char *path, const char *typespec)
Delete an OSC method from the specified server.
int lo_address_get_ttl(lo_address t)
Get the Time-to-Live value for a given target address.
void lo_blob_free(lo_blob b)
Free the memory taken by a blob.
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_server_recv_noblock(lo_server s, int timeout)
Look for an OSC message waiting to be received.
Server(const num_string_type &port, lo_err_handler err_h=0)
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_send_bundle(lo_address targ, lo_bundle b)
Send a lo_bundle object to address targ.
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...
void lo_server_free(lo_server s)
Free up memory used by the lo_server object.
void lo_address_set_ttl(lo_address t, int ttl)
Set the Time-to-Live value for a given target address.
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_get_socket_fd(lo_server s)
Return the file descriptor of the server socket.
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_bundle_add_bundle(lo_bundle b, lo_bundle n)
Adds an OSC bundle to an existing bundle.
void * lo_message
A low-level object used to represent messages passed over OSC.
int lo_server_dispatch_data(lo_server s, void *data, size_t size)
Dispatch a raw block of memory containing an OSC message.
int lo_address_set_stream_slip(lo_address t, int enable)
Set outgoing stream connections (e.g., TCP) to be transmitted using the SLIP packetizing protocol.