Structure to hold callbacks registered with adbus_conn_new(). More...
Data Fields | |
| adbus_Callback | release |
| Called when the connection is destroyed. | |
| adbus_SendMsgCallback | send_message |
| This is a callback to send messages. | |
| adbus_ProxyCallback | proxy |
| Callback to send messages across to the connection thread. | |
| adbus_ShouldProxyCallback | should_proxy |
| adbus_GetProxyCallback | get_proxy |
| adbus_BlockCallback | block |
Structure to hold callbacks registered with adbus_conn_new().
Callback to send messages across to the connection thread.
For example:
class ProxyEvent { public: ProxyEvent(adbus_Callback cb, adbus_Callback release, void* user) : m_Cb(cb), m_Release(release), m_User(user) {} ~ProxyEvent() { if (m_Release) m_Release(m_User); } void call() { if (m_Cb) m_Cb(m_User); } adbus_Callback m_Cb; adbus_Callback m_Release; void* m_User; }; void Proxy(void* user, adbus_Callback cb, adbus_Callback release, void* cbuser) { if (OnConnectionThread()) { ProxyEvent e(cb, release, user); e.call(); } else { ProxyEvent* e = new ProxyEvent(cb, release, user); PostEvent(e); } } // On the connection thread void ProcessEvent(ProxyEvent* e) { e->call(); delete e; }
Called when the connection is destroyed.
Since the connection is internally ref counted via adbus_conn_ref() and adbus_conn_deref() it can occur after the call to adbus_conn_free().
This is a callback to send messages.
The return value should be the number of bytes written or -1 on error (ie the return value of recv). The connection considers any value except the full message length to be an error.
For example:
adbus_ssize_t SendMsg(void* user, adbus_Message* m) { return send(*(adbus_Socket*) user, m->data, m->size, 0);
1.6.1