Class: NNG::Socket::Rep0
- Inherits:
-
Object
- Object
- NNG::Socket::Rep0
- Defined in:
- ext/rbnng/rep0.c
Instance Method Summary collapse
- #get_msg ⇒ Object
- #initialize ⇒ Object constructor
- #listen(url) ⇒ Object
- #send_msg(rb_strMsg) ⇒ Object
Constructor Details
#initialize ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/rbnng/rep0.c', line 121 static VALUE socket_rep0_initialize(VALUE self) { RbnngSocket* p_rbnngSocket; Data_Get_Struct(self, RbnngSocket, p_rbnngSocket); int rv; if ((rv = nng_rep0_open(&p_rbnngSocket->socket)) != 0) { raise_error(rv); } if ((rv = nng_ctx_open(&p_rbnngSocket->ctx, p_rbnngSocket->socket)) != 0) { raise_error(rv); } return self; } |
Instance Method Details
#get_msg ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'ext/rbnng/rep0.c', line 47 static VALUE socket_rep0_get_msg(VALUE self) { RbnngSocket* p_rbnngSocket; Data_Get_Struct(self, RbnngSocket, p_rbnngSocket); int rv = rb_thread_call_without_gvl(rep0_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; } } |
#listen(url) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'ext/rbnng/rep0.c', line 12 static VALUE socket_rep0_listen(VALUE self, VALUE url) { Check_Type(url, T_STRING); int rv; RbnngSocket* p_rbnngSocket; Data_Get_Struct(self, RbnngSocket, p_rbnngSocket); if ((rv = nng_listen(p_rbnngSocket->socket, StringValueCStr(url), NULL, 0)) != 0) { raise_error(rv); } } |
#send_msg(rb_strMsg) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'ext/rbnng/rep0.c', line 105 static VALUE socket_rep0_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(rep0_send_msg_blocking, &sendMsgReq, 0, 0); if (rv != 0) { raise_error(rv); } } |