Tells the server to begin listening for an incoming Web Socket connection in binary transmission mode.
server.beginWebSocketBinary(path)
server.beginWebSocketBinary(path, proto)
path - URI of the web socket
proto - protocol of the web socket
none
#include <Phpoc.h>
PhpocServer server(80);
void setup() {
Serial.begin(9600);
while(!Serial)
;
// initialize PHPoC [WiFi] Shield:
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
// start WebSocket server
server.beginWebSocketBinary("remote_push");
// print IP address of PHPoC [WiFi] Shield to serial monitor:
Serial.print("WebSocket server address : ");
Serial.println(Phpoc.localIP());
}
void loop() {
// wait for a new client:
PhpocClient client = server.available();
if (client) {
if (client.available() > 0) {
// read a byte incoming from the client:
char thisChar = client.read();
// when an user presses a button on the web apps, the web app sends an
// uppercase character corresponding with the name of button to Arduino.
// When an user releases a button on the web apps, the web app sends a
// lowercase character corresponding with the name of button to Arduino.
if(thisChar == 'A')
Serial.println("button A press");
if(thisChar == 'a')
Serial.println("button A release");
if(thisChar == 'B')
Serial.println("button B press");
if(thisChar == 'b')
Serial.println("button B release");
if(thisChar == 'C')
Serial.println("button C press");
if(thisChar == 'c')
Serial.println("button C release");
}
}
}