Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[windows] switch to WinsockWatcher when run on windows

  • Loading branch information...
commit 1f3a5cd9bec7a54f2bd1a4a97cc51f9e8f6a250e 1 parent ebdeff4
@agnat authored
View
16 dns_sd.gyp
@@ -21,22 +21,18 @@
, 'conditions': [
[ 'OS!="mac" and OS!="win"', {
'libraries': [ '-ldns_sd' ]
- }],
- ['OS=="win"', {
+ }]
+ , ['OS=="win"', {
'sources' : [ 'src/winsock_watcher.cpp' ]
, 'include_dirs': [ '$(BONJOUR_SDK_HOME)Include' ]
- , 'libraries' : [ '-l$(BONJOUR_SDK_HOME)Lib/Win32/dnssd.lib'
+ , 'libraries' : [ '-l$(BONJOUR_SDK_HOME)Lib/$(Platform)/dnssd.lib'
, '-lws2_32.lib'
]
- }],
+ }]
]
, 'msbuild_settings': {
- 'ClCompile': {
- 'ExceptionHandling': 'Sync' # /EHsc
- },
- 'Link': {
- 'IgnoreSpecificDefaultLibraries': [ 'LIBCMT' ]
- },
+ 'ClCompile': { 'ExceptionHandling': 'Sync' }
+ , 'Link' : { 'IgnoreSpecificDefaultLibraries': [ 'LIBCMT' ] }
}
}
]
View
9 lib/io_watcher.js
@@ -0,0 +1,9 @@
+if (process.platform === 'win32') {
+ var IOWatcher = exports.IOWatcher = require('./dns_sd').WinsockWatcher;
+
+ IOWatcher.prototype.start = function start() {}
+ IOWatcher.prototype.stop = function stop() {}
+
+} else {
+ exports.IOWatcher = process.binding('io_watcher').IOWatcher;
+}
View
3  lib/mdns_service.js
@@ -1,8 +1,7 @@
var dns_sd = require('./dns_sd')
, util = require('util')
, events = require('events')
- , IOWatcher = process.platform == 'win32' ? dns_sd.WinsockWatcher :
- process.binding('io_watcher').IOWatcher;
+ , IOWatcher = require('./io_watcher').IOWatcher;
;
function MDNSService() {
View
12 src/winsock_watcher.cpp
@@ -6,18 +6,16 @@ using namespace v8;
namespace node_mdns {
-Persistent<FunctionTemplate> WinsockWatcher::constructor_template;
-
void
WinsockWatcher::Initialize(Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(New);
- constructor_template = Persistent<FunctionTemplate>::New(t);
- constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
-
Local<String> symbol = String::NewSymbol("WinsockWatcher");
- constructor_template->SetClassName(symbol);
+ t->SetClassName(symbol);
+ t->InstanceTemplate()->SetInternalFieldCount(1);
+
+ NODE_SET_PROTOTYPE_METHOD(t, "set", Set);
- target->Set(symbol, constructor_template->GetFunction());
+ target->Set(symbol, t->GetFunction());
}
v8::Handle<v8::Value>
View
2  src/winsock_watcher.hpp
@@ -10,8 +10,6 @@ class WinsockWatcher : public node::ObjectWrap {
private:
static v8::Handle<v8::Value> New(const v8::Arguments & args);
static v8::Handle<v8::Value> Set(const v8::Arguments & args);
-
- static v8::Persistent<v8::FunctionTemplate> constructor_template;
};
} // end of namespace node_mdns
View
2  tests/test_dns_sd.js
@@ -320,7 +320,7 @@ exports['DNSServiceRegister()'] = function(t) {
exports['DNSServiceProcessResult()'] = function(t) {
var serviceRef = new dns_sd.DNSServiceRef()
- , IOWatcher = process.binding('io_watcher').IOWatcher
+ , IOWatcher = require('../lib/io_watcher').IOWatcher
, watcher = new IOWatcher()
, timeout = 3000
, timeoutId = setTimeout(function() {
Please sign in to comment.
Something went wrong with that request. Please try again.