Kaspar Schiess avatar Kaspar Schiess committed 354a9fa Merge

UNSUBSCRIBE: adding a trivial unsubscribe function to sub socket

(with "Paul Laidler <plaidler@gmail.com>")

Comments (0)

Files changed (3)

 mkmf.log
 ext/*.o
 ext/*.bundle
+
+web/vendor
 }
 
 static VALUE
+sub_sock_unsubscribe(VALUE socket, VALUE channel)
+{
+  int sock = sock_get(socket);
+  int err;
+
+  err = nn_setsockopt(
+    sock, NN_SUB, NN_SUB_UNSUBSCRIBE,
+    StringValuePtr(channel),
+    RSTRING_LEN(channel)
+  );
+  if (err < 0)
+    RAISE_SOCK_ERROR;
+
+  return socket;
+}
+
+static VALUE
 srvy_set_deadline(VALUE self, VALUE deadline)
 {
   int sock = sock_get(self);
   rb_define_method(cPubSocket, "initialize", pub_sock_init, -1);
   rb_define_method(cSubSocket, "initialize", sub_sock_init, -1);
   rb_define_method(cSubSocket, "subscribe", sub_sock_subscribe, 1);
+  rb_define_method(cSubSocket, "unsubscribe", sub_sock_unsubscribe, 1);
 
   rb_define_method(cSurveySocket, "initialize", srvy_sock_init, -1);
   rb_define_method(cSurveySocket, "deadline=", srvy_set_deadline, 1);
 
 Gem::Specification.new do |s|
   s.name = 'nanomsg'
-  s.version = '0.3.2'
+  s.version = '0.3.3'
 
   s.authors = ['Kaspar Schiess']
   s.email = 'kaspar.schiess@absurd.li'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.