Permalink
Browse files

adding send method

  • Loading branch information...
1 parent e853cee commit 91a7b0e520f7bda00ccf6210b9f1fa10a37dff7f @tenderlove committed Sep 22, 2008
Showing with 13 additions and 0 deletions.
  1. +13 −0 ext/quail/quail_exchange.c
View
13 ext/quail/quail_exchange.c
@@ -17,8 +17,21 @@ static VALUE create_exchange( VALUE self,
return INT2NUM(eid);
}
+static VALUE send(VALUE self, VALUE message)
+{
+ void * handle;
+
+ VALUE length = rb_funcall(message, rb_intern("length"), 0);
+ VALUE rb_h = rb_iv_get(self, "@handle");
+ VALUE eid = rb_iv_get(self, "@eid");
+ Data_Get_Struct(rb_h, void, handle);
+ czmq_send(handle, NUM2INT(eid), StringValuePtr(message), NUM2INT(length), 0);
+ return message;
+}
+
void Init_Quail_Exchange(VALUE mQuail)
{
VALUE cQuailHandle = rb_define_class_under(mQuail, "Exchange", rb_cObject);
rb_define_private_method(cQuailHandle, "create_exchange", create_exchange, 4);
+ rb_define_method(cQuailHandle, "send", send, 1);
}

0 comments on commit 91a7b0e

Please sign in to comment.