30 lines
621 B
C++
30 lines
621 B
C++
#include "Socket.h"
|
|
#include <nng/protocol/reqrep0/rep.h>
|
|
#include <nng/protocol/reqrep0/req.h>
|
|
|
|
namespace Nng {
|
|
|
|
Socket::Socket(Protocol protocol) {
|
|
if (protocol == Protocol::Bus) {
|
|
} else if (protocol == Protocol::Publisher) {
|
|
} else if (protocol == Protocol::Request) {
|
|
nng_req0_open(&m_socket);
|
|
} else if (protocol == Protocol::Reply) {
|
|
nng_rep0_open(&m_socket);
|
|
} else {
|
|
assert(true || "ggg");
|
|
}
|
|
}
|
|
|
|
Socket::~Socket() {
|
|
if (m_socket.id != 0) {
|
|
nng_close(m_socket);
|
|
}
|
|
}
|
|
|
|
int Socket::id() const {
|
|
return nng_socket_id(m_socket);
|
|
}
|
|
|
|
} // namespace Nng
|