2 #include "vg/vg_steam.h"
3 #include "vg/vg_steam_networking.h"
4 #include "vg/vg_steam_auth.h"
5 #include "vg/vg_steam_friends.h"
8 #include "network_msg.h"
9 #include "network_common.h"
10 #include "player_remote.h"
12 #include "world_sfd.h"
13 #include "world_routes.h"
14 #include "vg/vg_imgui.h"
16 #include "ent_region.h"
17 #include "vg/vg_loader.h"
23 #include <sys/socket.h>
24 #include <sys/types.h>
28 struct network_client network_client
=
30 .auth_mode
= eServerModeAuthentication
,
31 .state
= k_ESteamNetworkingConnectionState_None
,
32 .last_intent_change
= -99999.9
35 static void scores_update(void);
37 int packet_minsize( SteamNetworkingMessage_t
*msg
, u32 size
){
38 if( msg
->m_cbSize
< size
) {
39 vg_error( "Invalid packet size (must be at least %u)\n", size
);
47 static void on_auth_ticket_recieved( void *result
, void *context
){
48 EncryptedAppTicketResponse_t
*response
= result
;
50 if( response
->m_eResult
== k_EResultOK
){
51 vg_info( " New app ticket ready\n" );
54 vg_warn( " Could not request new encrypted app ticket (%u)\n",
55 response
->m_eResult
);
58 if( SteamAPI_ISteamUser_GetEncryptedAppTicket( hSteamUser
,
59 network_client
.app_symmetric_key
,
60 vg_list_size(network_client
.app_symmetric_key
),
61 &network_client
.app_key_length
)){
62 vg_success( " Loaded app ticket\n" );
65 vg_error( " No ticket availible\n" );
66 network_client
.app_key_length
= 0;
70 static void request_auth_ticket(void){
72 * TODO Check for one thats cached on the disk and load it.
73 * This might be OK though because steam seems to cache the result
76 vg_info( "Requesting new authorization ticket\n" );
78 vg_steam_async_call
*call
= vg_alloc_async_steam_api_call();
79 call
->userdata
= NULL
;
80 call
->p_handler
= on_auth_ticket_recieved
;
82 SteamAPI_ISteamUser_RequestEncryptedAppTicket( hSteamUser
, NULL
, 0 );
85 static void network_send_username(void){
86 if( !network_connected() )
89 netmsg_playerusername
*update
= alloca( sizeof(netmsg_playerusername
)+
90 NETWORK_USERNAME_MAX
);
91 update
->inetmsg_id
= k_inetmsg_playerusername
;
94 ISteamFriends
*hSteamFriends
= SteamAPI_SteamFriends();
95 const char *username
= SteamAPI_ISteamFriends_GetPersonaName(hSteamFriends
);
96 u32 chs
= str_utf8_collapse( username
, update
->name
, NETWORK_USERNAME_MAX
);
98 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
99 hSteamNetworkingSockets
, network_client
.remote
,
100 update
, sizeof(netmsg_playerusername
)+chs
+1,
101 k_nSteamNetworkingSend_Reliable
, NULL
);
104 void network_send_region(void)
106 if( !network_connected() )
109 netmsg_region
*region
= alloca( sizeof(netmsg_region
) + NETWORK_REGION_MAX
);
111 region
->inetmsg_id
= k_inetmsg_region
;
113 region
->flags
= global_ent_region
.flags
;
115 u32 l
= vg_strncpy( global_ent_region
.location
, region
->loc
,
116 NETWORK_REGION_MAX
, k_strncpy_always_add_null
);
118 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
119 hSteamNetworkingSockets
, network_client
.remote
,
120 region
, sizeof(netmsg_region
)+l
+1,
121 k_nSteamNetworkingSend_Reliable
, NULL
);
124 static void network_send_request( netmsg_request
*req
, vg_msg
*body
,
126 netmsg_request
*res
, vg_msg
*body
,
132 vg_info( "Request scoreboard. Info (%u):\n", body
->cur
.co
);
133 vg_msg_print( body
, len
);
135 if( body
->error
!= k_vg_msg_error_OK
){
136 vg_error( "Body not OK\n" );
142 req
->id
= vg_pool_lru( &network_client
.request_pool
);
144 vg_pool_watch( &network_client
.request_pool
, req
->id
);
145 struct network_request
*pn
=
146 vg_pool_item( &network_client
.request_pool
, req
->id
);
147 pn
->callback
= callback
;
148 pn
->sendtime
= vg
.time_real
;
149 pn
->userdata
= userdata
;
152 vg_error( "Unable to send request. Pool is full.\n" );
159 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
160 hSteamNetworkingSockets
, network_client
.remote
,
161 req
, sizeof(netmsg_request
)+len
,
162 k_nSteamNetworkingSend_Reliable
, NULL
);
165 static void network_scoreboard_callback( netmsg_request
*res
, vg_msg
*body
,
167 world_instance
*world
= world_current_instance();
169 world_routes_recv_scoreboard( world
, body
, userdata
, res
->status
);
170 if( userdata
== world_sfd
.active_route_board
)
171 world_sfd_compile_active_scores();
176 /* mod_uid: world mod uid,
177 * route_uid: run name (just a string)
181 * 2 ALL TIME + CURRENT WEEK
183 * 10+ specific week index
185 void network_request_scoreboard( const char *mod_uid
,
186 const char *route_uid
,
187 u32 week
, u64 userdata
){
188 if( !network_connected() )
191 netmsg_request
*req
= alloca( sizeof(netmsg_request
) + 512 );
192 req
->inetmsg_id
= k_inetmsg_request
;
195 vg_msg_init( &data
, req
->q
, 512 );
196 vg_msg_wkvstr( &data
, "endpoint", "scoreboard" );
197 vg_msg_wkvstr( &data
, "mod", mod_uid
);
198 vg_msg_wkvstr( &data
, "route", route_uid
);
199 vg_msg_wkvnum( &data
, "week", k_vg_msg_u32
, 1, &week
);
200 network_send_request( req
, &data
, network_scoreboard_callback
, userdata
);
203 static void network_publish_callback( netmsg_request
*res
, vg_msg
*body
,
205 if( res
->status
!= k_request_status_ok
){
206 vg_error( "Publish laptime, server error #%d\n", (i32
)res
->status
);
210 void network_publish_laptime( const char *mod_uid
,
211 const char *route_uid
, f64 lap_time
){
212 if( !network_connected() )
215 i32 time_centiseconds
= lap_time
* 100.0;
217 netmsg_request
*req
= alloca( sizeof(netmsg_request
) + 512 );
218 req
->inetmsg_id
= k_inetmsg_request
;
221 vg_msg_init( &data
, req
->q
, 512 );
222 vg_msg_wkvstr( &data
, "endpoint", "setlap" );
223 vg_msg_wkvstr( &data
, "mod", mod_uid
);
224 vg_msg_wkvstr( &data
, "route", route_uid
);
225 vg_msg_wkvnum( &data
, "time", k_vg_msg_i32
, 1, &time_centiseconds
);
226 network_send_request( req
, &data
, network_publish_callback
, 0 );
229 static void network_request_rx_300_400( SteamNetworkingMessage_t
*msg
){
230 netmsg_blank
*tmp
= msg
->m_pData
;
232 if( tmp
->inetmsg_id
== k_inetmsg_request
){
235 else if( tmp
->inetmsg_id
== k_inetmsg_response
){
236 netmsg_request
*res
= (netmsg_request
*)msg
->m_pData
;
241 if( res
->status
== k_request_status_ok
){
242 vg_msg_init( &data
, res
->q
, msg
->m_cbSize
- sizeof(netmsg_request
) );
243 vg_success( "Response to #%d:\n", (i32
)res
->id
);
244 vg_msg_print( &data
, data
.max
);
248 vg_warn( "Server response to #%d: %d\n", (i32
)res
->id
, res
->status
);
252 struct network_request
*pn
=
253 vg_pool_item( &network_client
.request_pool
, res
->id
);
254 pn
->callback( res
, body
, pn
->userdata
);
255 vg_pool_unwatch( &network_client
.request_pool
, res
->id
);
260 void network_send_item( enum netmsg_playeritem_type type
)
262 if( !network_connected() )
265 netmsg_playeritem
*item
=
266 alloca( sizeof(netmsg_playeritem
) + ADDON_UID_MAX
);
267 item
->inetmsg_id
= k_inetmsg_playeritem
;
268 item
->type_index
= type
;
271 if( (type
== k_netmsg_playeritem_world0
) ||
272 (type
== k_netmsg_playeritem_world1
) ){
274 enum world_purpose purpose
= type
- k_netmsg_playeritem_world0
;
275 addon_reg
*reg
= world_static
.instance_addons
[ purpose
];
278 addon_alias_uid( ®
->alias
, item
->uid
);
284 enum addon_type addon_type
= k_addon_type_none
;
285 if( type
== k_netmsg_playeritem_board
){
286 view_id
= localplayer
.board_view_slot
;
287 addon_type
= k_addon_type_board
;
289 else if( type
== k_netmsg_playeritem_player
){
290 view_id
= localplayer
.playermodel_view_slot
;
291 addon_type
= k_addon_type_player
;
294 struct addon_cache
*cache
= &addon_system
.cache
[addon_type
];
295 vg_pool
*pool
= &cache
->pool
;
297 SDL_AtomicLock( &addon_system
.sl_cache_using_resources
);
298 addon_cache_entry
*entry
= vg_pool_item( pool
, view_id
);
299 addon_alias_uid( &entry
->reg_ptr
->alias
, item
->uid
);
300 SDL_AtomicUnlock( &addon_system
.sl_cache_using_resources
);
303 vg_info( "send equip: [%u] %s\n",
304 item
->type_index
, item
->uid
);
305 u32 chs
= strlen(item
->uid
);
307 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
308 hSteamNetworkingSockets
, network_client
.remote
,
309 item
, sizeof(netmsg_playeritem
)+chs
+1,
310 k_nSteamNetworkingSend_Reliable
, NULL
);
313 static void network_disconnect(void){
314 SteamAPI_ISteamNetworkingSockets_CloseConnection(
315 hSteamNetworkingSockets
, network_client
.remote
, 0, NULL
, 0 );
316 network_client
.remote
= 0;
317 network_client
.state
= k_ESteamNetworkingConnectionState_None
;
319 for( int i
=0; i
<vg_list_size(netplayers
.list
); i
++ ){
320 netplayers
.list
[i
].active
= 0;
324 void network_status_string( vg_str
*str
, u32
*colour
)
326 if( skaterift
.demo_mode
){
327 vg_strcat( str
, "Offline" );
332 if( network_client
.user_intent
== k_server_intent_offline
){
333 vg_strcat( str
, "Offline" );
336 ESteamNetworkingConnectionState state
= network_client
.state
;
338 if( state
== k_ESteamNetworkingConnectionState_None
)
339 vg_strcat( str
, "No Connection" );
340 else if( state
== k_ESteamNetworkingConnectionState_Connecting
)
342 vg_strcatf( str
, "Connecting...\n%s", network_client
.host_adress
);
344 if( network_client
.retries
){
345 vg_strcat( str
, "\n(" );
346 vg_strcati32( str
, network_client
.retries
);
347 vg_strcat( str
, " retries)" );
350 else if( state
== k_ESteamNetworkingConnectionState_Connected
){
351 vg_strcatf( str
, "Connected to:\n%s", network_client
.host_adress
);
352 *colour
= 0xff00a020;
354 else if( state
== k_ESteamNetworkingConnectionState_ClosedByPeer
)
355 vg_strcat( str
, "Connection Closed" );
356 else if( state
== k_ESteamNetworkingConnectionState_FindingRoute
)
357 vg_strcat( str
, "Finding Route" );
359 k_ESteamNetworkingConnectionState_ProblemDetectedLocally
){
360 vg_strcat( str
, "Problem Detected\nLocally" );
361 *colour
= 0xff0000a0;
364 vg_strcat( str
, "???" );
368 vg_strcat( str
, "Steam Offline" );
369 *colour
= 0xff0000a0;
373 void render_server_status_gui(void)
375 render_fb_bind( gpipeline
.fb_workshop_preview
, 0 );
379 vg_ui
.cur_indice
= 0;
380 vg_ui
.vert_start
= 0;
381 vg_ui
.indice_start
= 0;
383 ui_rect r
= { 0, 0, 128, 48 };
387 vg_strnull( &str
, buf
, sizeof(buf
) );
390 network_status_string( &str
, &bg
);
393 ui_text( r
, buf
, 1, k_ui_align_center
, 0 );
394 ui_flush( k_ui_shader_colour
, 128, 48 );
396 skaterift
.rt_textures
[ k_skaterift_rt_server_status
] =
397 gpipeline
.fb_workshop_preview
->attachments
[0].id
;
400 static void on_server_connect_status( CallbackMsg_t
*msg
){
401 SteamNetConnectionStatusChangedCallback_t
*info
= (void *)msg
->m_pubParam
;
402 vg_info( " Connection status changed for %lu\n", info
->m_hConn
);
403 vg_info( " %s -> %s\n",
404 string_ESteamNetworkingConnectionState(info
->m_eOldState
),
405 string_ESteamNetworkingConnectionState(info
->m_info
.m_eState
) );
407 if( info
->m_hConn
== network_client
.remote
){
408 network_client
.state
= info
->m_info
.m_eState
;
410 if( info
->m_info
.m_eState
==
411 k_ESteamNetworkingConnectionState_Connected
){
412 vg_success(" Connected to remote server.. authenticating\n");
414 /* send version info to server */
415 netmsg_version version
;
416 version
.inetmsg_id
= k_inetmsg_version
;
417 version
.version
= NETWORK_SKATERIFT_VERSION
;
418 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
419 hSteamNetworkingSockets
, network_client
.remote
, &version
,
420 sizeof(netmsg_version
), k_nSteamNetworkingSend_Reliable
, NULL
);
422 /* TODO: We should really wait to see if the server is in auth mode
424 u32 size
= sizeof(netmsg_auth
) + network_client
.app_key_length
;
425 netmsg_auth
*auth
= alloca(size
);
426 auth
->inetmsg_id
= k_inetmsg_auth
;
427 auth
->ticket_length
= network_client
.app_key_length
;
428 for( int i
=0; i
<network_client
.app_key_length
; i
++ )
429 auth
->ticket
[i
] = network_client
.app_symmetric_key
[i
];
431 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
432 hSteamNetworkingSockets
, network_client
.remote
, auth
, size
,
433 k_nSteamNetworkingSend_Reliable
, NULL
);
435 else if( info
->m_info
.m_eState
==
436 k_ESteamNetworkingConnectionState_ClosedByPeer
){
438 if( info
->m_info
.m_eEndReason
==
439 k_ESteamNetConnectionEnd_Misc_InternalError
){
440 network_client
.retries
= 40;
442 network_disconnect();
444 else if( info
->m_info
.m_eState
==
445 k_ESteamNetworkingConnectionState_ProblemDetectedLocally
){
446 network_disconnect();
450 //vg_warn( " Recieved signal from unknown connection\n" );
453 render_server_status_gui();
456 static void on_persona_state_change( CallbackMsg_t
*msg
){
457 if( !network_connected() )
460 PersonaStateChange_t
*info
= (void *)msg
->m_pubParam
;
461 ISteamUser
*hSteamUser
= SteamAPI_SteamUser();
463 vg_info( "User: %llu, change: %u\n", info
->m_ulSteamID
,
464 info
->m_nChangeFlags
);
466 if( info
->m_ulSteamID
== SteamAPI_ISteamUser_GetSteamID(hSteamUser
) ){
467 if( info
->m_nChangeFlags
& k_EPersonaChangeName
){
468 network_send_username();
472 if( info
->m_nChangeFlags
& k_EPersonaChangeRelationshipChanged
){
473 for( u32 i
=0; i
<NETWORK_MAX_PLAYERS
; i
++ ){
474 struct network_player
*rp
= &netplayers
.list
[i
];
475 if( rp
->steamid
== info
->m_ulSteamID
){
476 player_remote_update_friendflags( rp
);
482 void network_set_host( const char *host_str
, const char *port_str
)
484 vg_strncpy( host_str
, network_client
.host_adress
,
485 sizeof(network_client
.host_adress
), k_strncpy_overflow_fatal
);
487 memset( &network_client
.ip
, 0, sizeof(network_client
.ip
) );
488 network_client
.ip_resolved
= 0;
492 vg_strncpy( port_str
, network_client
.host_port
,
493 sizeof(network_client
.host_port
), k_strncpy_overflow_fatal
);
498 vg_strnull( &str
, network_client
.host_port
,
499 sizeof(network_client
.host_port
) );
500 vg_strcati32( &str
, NETWORK_PORT
);
503 network_client
.ip
.m_port
= atoi( network_client
.host_port
);
506 static void network_connect(void)
508 VG_ASSERT( network_client
.ip_resolved
);
510 vg_info( "connecting...\n" );
511 network_client
.remote
= SteamAPI_ISteamNetworkingSockets_ConnectByIPAddress(
512 hSteamNetworkingSockets
, &network_client
.ip
, 0, NULL
);
515 static void network_sign_on_complete(void){
516 vg_success( "Sign on completed\n" );
518 /* send our init info */
519 network_send_username();
520 for( u32 i
=0; i
<k_netmsg_playeritem_max
; i
++ ){
521 network_send_item(i
);
523 network_send_region();
526 static void poll_remote_connection(void){
527 SteamNetworkingMessage_t
*messages
[32];
530 for( int i
=0; i
<10; i
++ ){
531 len
= SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection(
532 hSteamNetworkingSockets
, network_client
.remote
,
533 messages
, vg_list_size(messages
));
538 for( int i
=0; i
<len
; i
++ ){
539 SteamNetworkingMessage_t
*msg
= messages
[i
];
541 if( msg
->m_cbSize
< sizeof(netmsg_blank
) ){
542 vg_warn( "Discarding message (too small: %d)\n", msg
->m_cbSize
);
546 netmsg_blank
*tmp
= msg
->m_pData
;
548 if( (tmp
->inetmsg_id
>= 200) && (tmp
->inetmsg_id
< 300) ){
549 player_remote_rx_200_300( msg
);
551 else if( (tmp
->inetmsg_id
>= 300) && (tmp
->inetmsg_id
< 400) ){
552 network_request_rx_300_400( msg
);
555 if( tmp
->inetmsg_id
== k_inetmsg_version
){
556 netmsg_version
*version
= msg
->m_pData
;
557 if( version
->version
!= NETWORK_SKATERIFT_VERSION
){
558 network_disconnect();
559 /* we dont want to connect to this server ever */
560 network_client
.retries
= 999;
561 network_client
.last_attempt
= 999999999.9;
562 vg_error( "version mismatch with server\n" );
565 network_client
.remote_version
= version
->version
;
566 network_sign_on_complete();
571 SteamAPI_SteamNetworkingMessage_t_Release( msg
);
576 static void network_resolve_host_async( void *payload
, u32 size
)
578 u32
*status
= payload
;
579 network_client
.ip_resolved
= *status
;
582 SteamAPI_SteamNetworkingIPAddr_ToString( &network_client
.ip
, buf
, 256, 1 );
583 vg_info( "Resolved host address to: %s\n", buf
);
586 static void network_resolve_host_thread( void *_
)
588 vg_async_item
*call
= vg_async_alloc(8);
589 u32
*status
= call
->payload
;
592 if( (network_client
.host_adress
[0] >= '0') &&
593 (network_client
.host_adress
[0] <= '9') )
595 SteamAPI_SteamNetworkingIPAddr_ParseString(
597 network_client
.host_adress
);
598 network_client
.ip
.m_port
= atoi( network_client
.host_port
);
603 vg_info( "Resolving host.. %s (:%s)\n",
604 network_client
.host_adress
, network_client
.host_port
);
606 struct addrinfo hints
;
607 struct addrinfo
*result
;
609 /* Obtain address(es) matching host/port. */
611 memset( &hints
, 0, sizeof(hints
) );
612 hints
.ai_family
= AF_INET6
;
613 hints
.ai_socktype
= SOCK_DGRAM
;
614 hints
.ai_flags
= AI_V4MAPPED
| AI_ADDRCONFIG
;
615 hints
.ai_protocol
= 0;
617 int s
= getaddrinfo( network_client
.host_adress
, network_client
.host_port
,
622 vg_error( "getaddrinfo: %s\n", gai_strerror(s
) );
625 if( !strcmp( network_client
.host_adress
, "skaterift.com" ) )
627 vg_warn( "getaddrinfo failed for skaterift.com;\n "
628 "falling back to a hardcoded IPv4\n" );
629 strcpy( network_client
.host_adress
, "46.101.34.155" );
630 SteamAPI_SteamNetworkingIPAddr_ParseString(
632 network_client
.host_adress
);
633 network_client
.ip
.m_port
= NETWORK_PORT
;
640 struct sockaddr_in6
*inaddr
= (struct sockaddr_in6
*)result
->ai_addr
;
641 memcpy( network_client
.ip
.m_ipv6
, &inaddr
->sin6_addr
, 16 );
642 freeaddrinfo( result
);
646 end
: vg_async_dispatch( call
, network_resolve_host_async
);
649 void network_update(void)
654 ESteamNetworkingConnectionState state
= network_client
.state
;
656 if( network_client
.user_intent
== k_server_intent_offline
)
658 if( state
!= k_ESteamNetworkingConnectionState_None
)
659 network_disconnect();
664 if( state
== k_ESteamNetworkingConnectionState_Connected
)
666 poll_remote_connection();
667 f64 frame_delta
= vg
.time_real
- network_client
.last_frame
;
669 if( frame_delta
> NETWORK_FRAMERATE
)
671 network_client
.last_frame
= vg
.time_real
;
672 remote_player_send_playerframe();
673 localplayer
.sfx_buffer_count
= 0;
676 remote_player_debug_update();
680 if( (state
== k_ESteamNetworkingConnectionState_Connecting
) ||
681 (state
== k_ESteamNetworkingConnectionState_FindingRoute
) )
687 f64 waited
= vg
.time_real
- network_client
.last_attempt
,
690 if( network_client
.retries
> 5 )
693 if( waited
< min_wait
)
696 if( !network_client
.ip_resolved
)
698 if( vg_loader_availible() )
700 vg_loader_start( network_resolve_host_thread
, NULL
);
707 network_client
.retries
++;
708 network_client
.last_attempt
= vg
.time_real
;
713 void chat_send_message( const char *message
)
715 if( !network_connected() ){
719 netmsg_chat
*chat
= alloca( sizeof(netmsg_chat
) + NETWORK_MAX_CHAT
);
720 chat
->inetmsg_id
= k_inetmsg_chat
;
723 u32 l
= vg_strncpy( message
, chat
->msg
, NETWORK_MAX_CHAT
,
724 k_strncpy_always_add_null
);
726 SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
727 hSteamNetworkingSockets
, network_client
.remote
,
728 chat
, sizeof(netmsg_chat
)+l
+1,
729 k_nSteamNetworkingSend_Reliable
, NULL
);
732 static int cmd_network_send_message( int argc
, const char *argv
[] ){
733 char buf
[ NETWORK_MAX_CHAT
];
735 vg_strnull( &str
, buf
, NETWORK_MAX_CHAT
);
737 for( int i
=0; i
<argc
; i
++ ){
738 vg_strcat( &str
, argv
[i
] );
741 vg_strcatch( &str
, ' ' );
744 chat_send_message( buf
);
748 void network_init(void)
750 vg_console_reg_var( "network_info", &network_client
.network_info
,
751 k_var_dtype_i32
, VG_VAR_PERSISTENT
);
752 vg_console_reg_var( "auto_connect", &network_client
.auto_connect
,
753 k_var_dtype_i32
, VG_VAR_PERSISTENT
);
755 u32 alloc_size
= sizeof(struct network_request
)*NETWORK_MAX_REQUESTS
;
756 network_client
.request_buffer
=
757 vg_linear_alloc( vg_mem
.rtmemory
, alloc_size
);
758 memset( network_client
.request_buffer
, 0, alloc_size
);
760 vg_pool
*pool
= &network_client
.request_pool
;
761 pool
->buffer
= network_client
.request_buffer
;
762 pool
->count
= NETWORK_MAX_REQUESTS
;
763 pool
->stride
= sizeof( struct network_request
);
764 pool
->offset
= offsetof( struct network_request
, poolnode
);
765 vg_pool_init( pool
);
767 steam_register_callback( k_iSteamNetConnectionStatusChangedCallBack
,
768 on_server_connect_status
);
769 steam_register_callback( k_iPersonaStateChange
,
770 on_persona_state_change
);
771 request_auth_ticket();
773 vg_console_reg_cmd( "say", cmd_network_send_message
, NULL
);
777 void network_end(void)
779 /* TODO: Send buffered highscores that were not already */
780 if( (network_client
.state
== k_ESteamNetworkingConnectionState_Connected
) ||
781 (network_client
.state
== k_ESteamNetworkingConnectionState_Connecting
) )
783 SteamAPI_ISteamNetworkingSockets_CloseConnection(
784 hSteamNetworkingSockets
, network_client
.remote
, 0, NULL
, 1 );