web項目中直接進行下面調用
Gateway::isOnline("7f0000010b5600000006")
報錯
[attach]193[/attach]
調用就是按照手冊寫,就只有一行
Gateway::isOnline("7f0000010b5600000006")
[attach]194[/attach]
[attach]195[/attach]
$gateway->name = 'YourAppGateway';
// gateway進程數(shù)
$gateway->count = 4;
// 本機ip,分布式部署時使用內網ip
$gateway->lanIp = '114.119.44.225';
// 內部通訊起始端口,假如$gateway->count=4,起始端口為4000
// 則一般會使用4000 4001 4002 4003 4個端口作為內部通訊端口
$gateway->startPort = 2900;
// 服務注冊地址
$gateway->registerAddress = '127.0.0.1:1238';
改成外網ip后啟動
[attach]197[/attach]
報錯
start_register.php start_gateway.php start_businessworker.php
里的ip都改為服務器的真實ip ,不要用127.0.0.1
/**
* client_id到通訊地址的轉換
* @return array
*/
public static function clientIdToAddress($client_id)
{
if(strlen($client_id) !== 20)
{
throw new \Exception("client_id $client_id is invalid");
}
$result = unpack('Nlocal_ip/nlocal_port/Nconnection_id' ,pack('H*', $client_id));
$result = ip2long("服務器外網ip");
// return unpack('Nlocal_ip/nlocal_port/Nconnection_id' ,pack('H*', $client_id));
return $result;
}