Created
April 12, 2013 09:05
-
-
Save philippbosch/5370680 to your computer and use it in GitHub Desktop.
WebSockets example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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