- if( cremote_state == k_ESteamNetworkingConnectionState_Connected )
- {
- /*
- * request updated scores, this does not require any authentication.
- */
- netmsg_scores_request req;
- req.inetmsg_id = k_inetmsg_scores_request;
-
- SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
- hSteamNetworkingSockets, cremote, &req,
- sizeof(netmsg_scores_request),
- k_nSteamNetworkingSend_Reliable, NULL );
-
- /*
- * Send record update, it requires authentication
- */
- if( steam_app_ticket_length )
- {
- }
- }
- else
- {
- /*
- * if we are not connected, make a connection to the server and then in
- * the future this function will be called again when it is connected
- */
- server_connect();
- }
-}
-
-static void poll_connection(void)
-{
- SteamNetworkingMessage_t *messages[32];
- int len;
-
- while(1)
- {
- len = SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection(
- hSteamNetworkingSockets, cremote, messages, vg_list_size(messages));
-
- if( len <= 0 )
- return;
-
- for( int i=0; i<len; i++ )
- {
- SteamNetworkingMessage_t *msg = messages[i];
-
- if( msg->m_cbSize < sizeof(netmsg_blank) )
- {
- vg_warn( "Discarding message (too small: %d)\n",
- msg->m_cbSize );
- continue;
- }
-
- netmsg_blank *tmp = msg->m_pData;
- if( tmp->inetmsg_id == k_inetmsg_scores_info )
- {
- netmsg_scores_info *info = msg->m_pData;
- vg_log( "Recieved %u score records\n", info->record_count );
-
- SteamAPI_ISteamNetworkingSockets_CloseConnection(
- hSteamNetworkingSockets, cremote, 0, NULL, 1 );
- cremote_state = k_ESteamNetworkingConnectionState_None;
- }
-
- SteamAPI_SteamNetworkingMessage_t_Release( msg );
- }
- }
-}
-
-static u64 in_server_ticks( double seconds )
-{
- return (u64)(seconds / 0.1);
-}
-
-static void on_server_connect_status( CallbackMsg_t *msg )
-{
- SteamNetConnectionStatusChangedCallback_t *info = (void *)msg->m_pubParam;
- vg_info( " Connection status changed for %lu\n", info->m_hConn );
- vg_info( " %s -> %s\n",
- string_ESteamNetworkingConnectionState(info->m_info.m_eState),
- string_ESteamNetworkingConnectionState(info->m_eOldState) );
-
- if( info->m_hConn == cremote )
- {
- cremote_state = info->m_info.m_eState;
- if( info->m_info.m_eState ==
- k_ESteamNetworkingConnectionState_Connected )
- {
- vg_success(" Connected to remote server\n");
- scores_update();
- }
- }
- else
- {
- vg_warn( " Recieved signal from unknown connection\n" );