File: testgripwebsocket.php

package info (click to toggle)
pushpin 1.41.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,056 kB
  • sloc: cpp: 44,382; python: 1,305; sh: 139; makefile: 73; javascript: 34; php: 27
file content (21 lines) | stat: -rw-r--r-- 416 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

$body = @file_get_contents('php://input');

header('Content-Type: application/websocket-events');

if (substr($body, 0, 6) === "OPEN\r\n") {
    header('Sec-WebSocket-Extensions: grip; message-prefix=""');
    $sub = True;
} else {
    $sub = False;
}

print $body;

if ($sub) {
    $msg = 'c:{"type": "subscribe", "channel": "test"}';
    print 'TEXT ' . dechex(strlen($msg)) . "\r\n" . $msg . "\r\n";
}

?>