Permalink
Browse files

Fixed #276

  • Loading branch information...
1 parent 3b5a91a commit e3fc3b81adc057a3cf45a6b3b76bb80fd93291f7 @kkoopa committed Feb 8, 2014
Showing with 15 additions and 34 deletions.
  1. +14 −14 binding.cc
  2. +0 −18 test/test.socket.hwm.3-x.js
  3. +1 −2 test/test.socket.messages.lateconnect.js
View
@@ -106,8 +106,8 @@ namespace zmq {
static Socket* GetSocket(_NAN_METHOD_ARGS);
static NAN_GETTER(GetState);
- static Handle<Value> GetPending(Local<String> p, const AccessorInfo& info);
- static void SetPending(Local<String> p, Local<Value> v, const AccessorInfo& info);
+ static NAN_GETTER(GetPending);
+ static NAN_SETTER(SetPending);
template<typename T>
Handle<Value> GetSockOpt(int option);
@@ -325,7 +325,7 @@ namespace zmq {
if (rc < 0) {
throw std::runtime_error(ErrorMessage());
}
- return item.revents & (ZMQ_POLLIN);
+ return item.revents & item.events;
}
void
@@ -482,20 +482,20 @@ namespace zmq {
NanReturnValue(Integer::New(socket->state_));
}
- Handle<Value>
- Socket::GetPending(Local<String> p, const AccessorInfo& info) {
- Socket* socket = ObjectWrap::Unwrap<Socket>(info.Holder());
- return Integer::New(socket->pending_);
+ NAN_GETTER(Socket::GetPending) {
+ NanScope();
+ Socket* socket = ObjectWrap::Unwrap<Socket>(args.Holder());
+ NanReturnValue(Integer::New(socket->pending_));
}
- void
- Socket::SetPending(Local<String> p, Local<Value> v, const AccessorInfo& info) {
- if (!v->IsNumber())
- ThrowException(Exception::TypeError(
- String::New("Pending must be an integer")));
+ NAN_SETTER(Socket::SetPending) {
+ NanScope();
+ if (!value->IsNumber()) {
+ NanThrowTypeError("Pending must be an integer");
+ }
- Socket* socket = ObjectWrap::Unwrap<Socket>(info.Holder());
- socket->pending_ = v->Int32Value();
+ Socket* socket = ObjectWrap::Unwrap<Socket>(args.Holder());
+ socket->pending_ = value->Int32Value();
}
template<typename T>
@@ -1,18 +0,0 @@
-
-var zmq = require('../')
- , should = require('should')
- , semver = require('semver')
- , sock = zmq.socket('req');
-
-if (semver.satisfies(zmq.version, '3.x')) {
- // ZMQ_SNDHWM
- sock.getsockopt(zmq.ZMQ_SNDHWM).should.not.equal(1);
- sock.setsockopt(zmq.ZMQ_SNDHWM, 1).should.equal(sock);
- sock.getsockopt(zmq.ZMQ_SNDHWM).should.equal(1);
- // ZMQ_RCVHWM
- sock.getsockopt(zmq.ZMQ_RCVHWM).should.not.equal(1);
- sock.setsockopt(zmq.ZMQ_RCVHWM, 1).should.equal(sock);
- sock.getsockopt(zmq.ZMQ_RCVHWM).should.equal(1);
-}
-
-sock.close();
@@ -1,4 +1,3 @@
-
var zmq = require('../')
, should = require('should')
, semver = require('semver');
@@ -29,7 +28,7 @@ setTimeout(function () {
n.should.equal(3);
}, 1*1000);
-if (semver.satisfies(zmq.version, '3.x')) {
+if (semver.satisfies(zmq.version, '>=3.x')) {
push.setsockopt(zmq.ZMQ_SNDHWM, 1);
pull.setsockopt(zmq.ZMQ_RCVHWM, 1);
} else if (semver.satisfies(zmq.version, '2.x')) {

0 comments on commit e3fc3b8

Please sign in to comment.