Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: websocket support #28

Open
brucelane opened this issue Sep 4, 2018 · 6 comments
Open

feature request: websocket support #28

brucelane opened this issue Sep 4, 2018 · 6 comments

Comments

@brucelane
Copy link
Contributor

hi, wouldn't be nice to have the generated fragment shader from the hydra code sent via websockets to another pc on the network?

@ojack
Copy link
Member

ojack commented Sep 4, 2018

yes! there is already websockets as well as webrtc, its just a matter of deciding on an api.
i have sent code via websockets here: https://github.com/ojack/hydra-sync

could you explain a little more how you would imagine using it?

@brucelane
Copy link
Contributor Author

it could be running other browsers on the network without having the need to stream with webrtc as fragment shaders and uniforms are sent as text, very lightweight on the bandwidth.
But I got another plan which is to feed my own VJ software with these fragment shaders and uniforms in a standalone visualizer app made with Cinder.

@ojack
Copy link
Member

ojack commented Sep 4, 2018

There is a function pb.broadcast() to send text via websockets, pb.sendToPeer() to send text via webrtc to a specific peer, or pb.sendToAll() to send to all connections via webrtc.... but they are only used internally right now. I need to look it over to make it a bit more usable.

@brucelane
Copy link
Contributor Author

great! at this point I have to check your code before talking without knowing ;-)

@micuat
Copy link
Member

micuat commented Jan 2, 2021

sorry for bumping an old thread but I just tested websocket to pass parameters. example app on processing:

import websockets.*;

WebsocketServer ws;

void setup(){
  size(600,200);
  ws= new WebsocketServer(this,8025,"/");
  frameRate(10);
}

void draw(){
  ws.sendMessage("0,"+map(mouseX,0,width,0,1));
}

void webSocketServerEvent(String msg){
 println(msg);
}

then running this on hydra console:

const socket = new WebSocket('ws://localhost:8025/');

// Connection opened
socket.addEventListener('open', function (event) {
  socket.send('Hello Server!');
});

var dd=Array(128).fill(0.5)

socket.addEventListener('message', function (event) {
  let [index, val] = event.data.split(",");
  //console.log(index, val)
  dd[index] = parseFloat(val);
});

and for example

osc(30,0.01,()=>dd[0]).out()

Should I go ahead and add a page in the doc folder? Of course the "API" can be improved by using stringified JSON, for example.

@brucelane
Copy link
Contributor Author

Since 2018, I added websocket support on all my forks of Hydra and it works fine.
hydracinder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants