Class: NNG::Socket::Req0
- Inherits:
-
Object
- Object
- NNG::Socket::Req0
- Defined in:
- ext/rbnng/req0.c
Instance Method Summary collapse
- #dial(url) ⇒ Object
- #get_msg ⇒ Object
- #initialize ⇒ Object constructor
- #send_msg(rb_strMsg) ⇒ Object
Constructor Details
#initialize ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'ext/rbnng/req0.c', line 12
static VALUE
socket_req0_initialize(VALUE self)
{
RbnngSocket* p_rbnngSocket;
Data_Get_Struct(self, RbnngSocket, p_rbnngSocket);
int rv;
if ((rv = nng_req0_open(&p_rbnngSocket->socket)) != 0) {
raise_error(rv);
return Qnil;
}
return self;
}
|
Instance Method Details
#dial(url) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/rbnng/socket.c', line 102
VALUE
socket_dial(VALUE self, VALUE url)
{
Check_Type(url, T_STRING);
RbnngSocket* p_rbnngSocket;
Data_Get_Struct(self, RbnngSocket, p_rbnngSocket);
int rv;
if ((rv = nng_dial(p_rbnngSocket->socket, StringValueCStr(url), 0, 0)) != 0) {
raise_error(rv);
}
}
|
#get_msg ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'ext/rbnng/socket.c', line 39
VALUE
socket_get_msg(VALUE self)
{
RbnngSocket* p_rbnngSocket;
Data_Get_Struct(self, RbnngSocket, p_rbnngSocket);
int rv =
rb_thread_call_without_gvl(socket_get_msg_blocking, p_rbnngSocket, 0, 0);
if (rv == 0) {
RbnngMsg* p_newMsg;
VALUE newMsg = rb_class_new_instance(0, 0, rbnng_MsgClass);
Data_Get_Struct(newMsg, RbnngMsg, p_newMsg);
p_newMsg->p_msg = p_rbnngSocket->p_getMsgResult;
return newMsg;
} else {
raise_error(rv);
return Qnil;
}
}
|
#send_msg(rb_strMsg) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/rbnng/socket.c', line 87
VALUE
socket_send_msg(VALUE self, VALUE rb_strMsg)
{
Check_Type(rb_strMsg, T_STRING);
RbnngSendMsgReq sendMsgReq = {
.socketObj = self,
.nextMsg = rb_strMsg,
};
int rv =
rb_thread_call_without_gvl(socket_send_msg_blocking, &sendMsgReq, 0, 0);
if (rv != 0) {
raise_error(rv);
}
}
|