Skip to content

Instantly share code, notes, and snippets.

@philippbosch
Created April 12, 2013 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippbosch/5370680 to your computer and use it in GitHub Desktop.
Save philippbosch/5370680 to your computer and use it in GitHub Desktop.
WebSockets example
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>WebSocket Test</title>
</head>
<body>
<script>
var ws = new WebSocket('ws://172.18.246.234:8080/p5websocket');
ws.onopen = function() {
ws.send('Ping');
};
</script>
</body>
</html>
WebSocketP5 socket;
void setup() {
socket = new WebSocketP5(this, 8080);
}
void draw() {
}
void stop(){
socket.stop();
}
void websocketOnMessage(WebSocketConnection con, String msg){
println(msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment