|
|
@@ -39,7 +39,7 @@ $gateway->registerAddress = '127.0.0.1:1238';
|
|
|
// 心跳数据
|
|
|
//$gateway->pingData = '{"type":"ping"}';
|
|
|
|
|
|
-/*
|
|
|
+
|
|
|
// 当客户端连接上来时,设置连接的onWebSocketConnect,即在websocket握手时的回调
|
|
|
$gateway->onConnect = function($connection)
|
|
|
{
|
|
|
@@ -47,15 +47,16 @@ $gateway->onConnect = function($connection)
|
|
|
{
|
|
|
// 可以在这里判断连接来源是否合法,不合法就关掉连接
|
|
|
// $_SERVER['HTTP_ORIGIN']标识来自哪个站点的页面发起的websocket链接
|
|
|
- if($_SERVER['HTTP_ORIGIN'] != 'http://kedou.workerman.net')
|
|
|
+ if(strpos($_SERVER['HTTP_ORIGIN'], 'huaml.com') === false)
|
|
|
{
|
|
|
$connection->close();
|
|
|
}
|
|
|
+
|
|
|
// onWebSocketConnect 里面$_GET $_SERVER是可用的
|
|
|
// var_dump($_GET, $_SERVER);
|
|
|
};
|
|
|
};
|
|
|
-*/
|
|
|
+
|
|
|
|
|
|
// 如果不是在根目录启动,则运行runAll方法
|
|
|
if(!defined('GLOBAL_START'))
|