void Sharedmemory_update(void) \r
{\r
\r
- static size_t bt_end = sizeof( bool_t ) * 8, //compute once\r
- et_end = sizeof( etimer_t ) * 3,\r
- pa_end = sizeof( float ) * 4,\r
- pc_end = sizeof( uint32_t ) * 2;\r
+ static size_t bt_end = sizeof( bool_t ) * 8, //compute once\r
+ pa_end = sizeof( float ) * 4,\r
+ pc_end = sizeof( uint32_t ) * 2;\r
\r
unsigned int cc = 0;\r
client_t *client_itr = NULL;\r
+ uint64_t now;\r
\r
memset( &shmptr->client[0], 0, sizeof( shmclient_t ) * shmptr->server_max_clients );\r
shmptr->clientcount = Client_count();\r
\r
- \r
- \r
+ if( shmptr->clientcount )\r
+ {\r
+ Timer_init( &now );\r
while( Client_iterate(&client_itr) != NULL ) {\r
- \r
-\r
- \r
+ \r
if( client_itr->authenticated )\r
- {\r
- \r
+ { \r
channel_t *channel = client_itr->channel;\r
- \r
+ \r
strncpy( shmptr->client[cc].username, client_itr->username, 120 );\r
- strncpy( shmptr->client[cc].ipaddress, Util_clientAddressToString( client_itr ) , 45 );\r
+ strncpy( shmptr->client[cc].ipaddress, Util_clientAddressToString( client_itr ), 45 );\r
shmptr->client[cc].tcp_port = Util_clientAddressToPortTCP( client_itr );\r
shmptr->client[cc].udp_port = Util_clientAddressToPortUDP( client_itr );\r
strncpy( shmptr->client[cc].channel, channel->name, 120 );\r
+ \r
+ shmptr->client[cc].online_secs = ( now - client_itr->connectTime ) / 1000000LL;\r
+ shmptr->client[cc].idle_secs = ( now - client_itr->idleTime ) / 1000000LL;\r
+ \r
memcpy( &shmptr->client[cc].bUDP, &client_itr->bUDP, bt_end );\r
- memcpy( &shmptr->client[cc].lastActivity, &client_itr->lastActivity, et_end );\r
memcpy( &shmptr->client[cc].UDPPingAvg, &client_itr->UDPPingAvg, pa_end );\r
memcpy( &shmptr->client[cc].UDPPackets, &client_itr->UDPPackets, pc_end );\r
} \r
- cc++;\r
- \r
+ cc++; \r
}\r
- \r
+\r
+} \r
}\r
\r
void Sharedmemory_deinit(void) \r