From b7eb0727d2ed48bb22aca051002da25cf6b8529b Mon Sep 17 00:00:00 2001 From: Futomi Hatano Date: Sun, 11 Feb 2018 20:32:19 +0900 Subject: [PATCH] Supported node v8 --- sample/README.md | 6 ++++-- sample/manager/server.js | 16 +++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sample/README.md b/sample/README.md index 0288fc3..acdf103 100644 --- a/sample/README.md +++ b/sample/README.md @@ -12,7 +12,7 @@ Before you try the ONVIF Network Camera Manager, you have to install some Node m ``` $ cd ~ $ npm install node-onvif -$ npm install websocket.io +$ npm install websocket ``` You can starts the `server.js` as follows: @@ -43,8 +43,10 @@ I tryed some ONVIF network cameras as follows: - [Panasonic BB-SC384B](http://sol.panasonic.biz/security/netwkcam/lineup/sc384b.html) - Though this model is sold in Japan, it seems to be sold in other contries as a different model name, such as WV-SC384 in [United Kingdom](http://business.panasonic.co.uk/security-solutions/products-and-accessories/video-surveillance/ip-security-systems-and-products/network-ptz-dome-security-cameras/wv-sc384?_ga=1.208388497.2069730874.1479653348) and [France](http://business.panasonic.fr/solutions-de-securite/produits-et-accessoires-panasonic-pour-cameras-professionnelles/produits-de-securite/produits-ip/cameras-domes-reseau-ptz/wv-sc384). - This application works completely with this model. +- [Canon VB-S30D](http://cweb.canon.jp/webview/lineup/vbs30d/index.html) [[Japan](http://cweb.canon.jp/webview/lineup/vbs30d/index.html)][[USA](https://www.usa.canon.com/internet/portal/us/home/support/details/network-video-solutions/all-network-cameras/vb-s30d/vb-s30d)][[France](https://www.canon.fr/for_work/business-products/network-cameras/vb-s30d/)][[UK](https://www.canon.co.uk/for_work/business-products/network-cameras/vb-s30d/)] + - This application works completely with this model. - [Sumpple S822](http://www.sumpple.com/enterprise/product/view/13) - This model supports both of PTZ and snapshot, but zoom is not supported. - PTZ is really slow. - [DBPOWER Home Surveillance Camera](http://www.dbpow.com/VA0130.html) - - This model supports snapshot though PTZ is not supported. + - This model supports snapshot while PTZ is not supported. diff --git a/sample/manager/server.js b/sample/manager/server.js index b7b7406..d2b0924 100644 --- a/sample/manager/server.js +++ b/sample/manager/server.js @@ -7,7 +7,7 @@ try { } catch(e) { onvif = require('node-onvif'); } -var ws = require('websocket.io'); +var WebSocketServer = require('websocket').server; var http = require('http'); var fs = require('fs'); var port = 8880; @@ -17,8 +17,10 @@ var port = 8880; http_server.listen(port, function() { console.log("Listening on port " + port); }); - var wsserver = ws.attach(http_server); - wsserver.on('connection', wsServerRequest); + var wsserver = new WebSocketServer({ + httpServer: http_server, + }); + wsserver.on('request', wsServerRequest); })(); function httpServerRequest(req, res) { @@ -83,9 +85,13 @@ function httpServerResponse404(url, res) { var client_list = []; -function wsServerRequest(conn) { +function wsServerRequest(request) { + var conn = request.accept(null, request.origin); conn.on("message", function(message) { - var data = JSON.parse(message); + if(message.type !== 'utf8') { + return; + } + var data = JSON.parse(message.utf8Data); var method = data['method']; var params = data['params']; if(method === 'startDiscovery') {