123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- define(["module", "vwf/view", "vwf/view/oscjs/dist/osc-module"], function(module, view, osc) {
- return view.load(module, {
- initialize: function() {
-
- self = this;
- this.osc = osc;
- this.portValue = '8081';
- this.hostValue = 'localhost';
- this.port = null;
-
- window._OSCManager = this;
- },
-
-
-
-
- setOSCHostAndPort: function(h,p) {
- this.hostValue = h;
- this.portValue = p;
-
- },
- connect: function() {
-
- this.disconnect();
- this.port = new osc.WebSocketPort({
- url: 'ws://' + this.hostValue + ':' + this.portValue
-
- });
-
- this.port.on("message", function (oscMessage) {
- console.log("message", oscMessage);
- findAllNodesWithOSC(oscMessage);
- });
- this.port.open();
- },
- disconnect: function() {
- console.log('disconnect');
- if (this.port !== null)
- this.port.close(1000, 'manual close');
- },
- getStatus: function() {
- if (this.port){
- return this.port.socket.readyState
- }
- return 3
- }
-
- })
- function findAllNodesWithOSC(oscMessage){
- var children = vwf.children(vwf.application());
- children.forEach(function(child){
- var oscprop = vwf.getProperty(child, 'osc');
- if (oscprop !== undefined){
- if (oscprop){
-
- vwf_view.kernel.callMethod(child, 'getOSC', [oscMessage]);
- }
- }
- })
-
-
-
-
-
-
-
- }
- });
|