Closed sm2017 closed 7 years ago
Here are the codes to generate clientId in Lib/Context.php.
$client_id = bin2hex(pack('NnN', $local_ip, $local_port, $connection_id));
$locol_ip
is $gateway->localIp
(defined in start_gateway.php) witch is unique in your server clusters.
$local_port
is internal communication port(related $gateway->startPort
in start_gateway.php) witch is unique for every gateway process in one server.
$connection_id
is the real socket id in gateway process witch is self-increasing when connection coming and is unique in one gateway process.
The max value for $connection_id
is 4294967295 (unsigned int), and connection_id will be set to 1 again when it reached the max value, this will not be happen in several tens of years.
So, clientId is unique in multiple server ( Distributed Deployment )
When a clientId is used the clientId will not be used again for a long time(several tens of years or even longer) in runtime.
Ok , Thanks
I want to know how
clientId
is generated?Is it unique in multiple server ( Distributed Deployment )? that means If we have 3 server and I have clientId
A
in server 1 , is it possible some one or me haveA
as client id in server 2 or 3 ?Is it unique in time , that means If my clientId is
B
and I close connection is it possible later some one or me haveB
as client id?