osc: wrap module, add utf encoding/decoding (#455)

This commit is contained in:
jean-emmanuel 2019-01-13 11:55:23 +01:00
parent 4323e9abbd
commit f990a05cd4
5 changed files with 29 additions and 2 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## 0.41.3
- osc
- add support for utf8 string argments (encoded/decoded as per standard https://encoding.spec.whatwg.org/#utf-8)
## 0.41.2
- bug fixes

View file

@ -60,6 +60,7 @@
"stacktrace-js": "2.0.0",
"through": "2.3.8",
"uglifyify": "5.0.1",
"utf8": "^3.0.0",
"ws": "6.1.2",
"yargs": "12.0.5"
},

21
src/server/osc/osc.js Normal file
View file

@ -0,0 +1,21 @@
var osc = require('osc/src/osc.js'),
transports = require('osc/src/platforms/osc-node.js'),
utf8 = require('utf8')
osc.UDPPort = transports.UDPPort
osc.TCPSocketPort = transports.TCPSocketPort
osc.writeUtfString = (str)=>{
return osc.writeString(utf8.encode(str))
}
osc.readUtfString = (dv, offsetState)=>{
return utf8.decode(osc.readString(dv, offsetState))
}
osc.argumentTypes.s = osc.argumentTypes.S = {
reader: 'readUtfString',
writer: 'writeUtfString'
}
module.exports = osc

View file

@ -1,4 +1,4 @@
var osc = require('osc'),
var osc = require('./osc'),
EventEmitter = require('events').EventEmitter,
settings = require('../settings'),
zeroconf = require('../zeroconf'),

View file

@ -1,4 +1,4 @@
var osc = require('osc'),
var osc = require('./osc'),
settings = require('../settings'),
zeroconf = require('../zeroconf'),
oscInPort = settings.read('oscInPort') || settings.read('httpPort')