js
var wsServer = 'ws://localhost:9501';
var websocket = new WebSocket(wsServer);
websocket.onopen = function (evt) {
console.log("Connected to WebSocket server.");
};
websocket.onclose = function (evt) {
console.log("Disconnected");
};
websocket.onmessage = function (evt) {
console.log('一起学swoole: ' + evt.data);
};
websocket.onerror = function (evt, e) {
console.log('Error occured: ' + evt.data);
};
php
public function push() {
print_r($_GET);
print_r($_POST['http_server']);
$_POST['http_server']->push(1, 'helle-Alan-push-data-1');
$_POST['http_server']->push(2, 'helle-Alan-push-data-2');
$_POST['http_server']->push(3, 'helle-Alan-push-data-3');
$_POST['http_server']->push(4, 'helle-Alan-push-data-4');
}
可以打印出get和$_POST[‘http_server’]的值,也可以接收到open的push值,但是接收不到Message的值???