Dwa/trzy linki dla zgłębienia wiedzy.
http://stackoverflow.com/questions/8125507...the-server-side
http://tools.ietf.org/html/rfc6455#section-6.1
http://tools.ietf.org/html/rfc6455#section-5.2
Muszę zaznaczyć że będę wysyłał tylko string < 125 bo to jest ważne. Dłuższe wiadomości mnie nie interesują.
Kod który jest odpowiedzialny za opakowanie wiadomości:
function wrap($msg=null){ if( $msg == null) return false; if( $length > 125) return false; $secondByte =(int) str_pad($length, 8, '0', STR_PAD_LEFT); // pierwszy bit zawsze bedzie 0 , potem wypełniamy 0 i długość return $firstByte.$secondByte.$msg; }//end of wrap
Problem z konsoli:
Kod
WebSocket connection to 'ws://localhost:12345/websocket/server.php' failed: A server must not mask any frames that it sends to the client.