13 protected static string m_InviteServerIP;
14 protected static int m_InviteServerPort;
15 protected static string m_CurrentServerIP;
16 protected static int m_CurrentServerPort;
17 protected static ref GetServersResultRow m_CurrentServerInfo;
24 protected static bool m_FirstFriendsLoad =
true;
25 protected static bool m_MultiplayState =
false;
28 protected static ref
BiosUser m_BiosUser;
32 #ifdef PLATFORM_CONSOLE
33 #ifndef PLATFORM_WINDOWS // if app is not on Windows with -XBOX parameter
34 if ( !m_TrialService )
40 if ( !m_PermissionsList )
43 m_FriendsList.Clear();
44 m_PermissionsList.Clear();
52 static bool IsInitialized()
54 return ( m_ClientServices !=
null );
57 static void GetClientServices()
62 BiosUser selected_user = user_manager.GetSelectedUser();
65 m_ClientServices = selected_user.GetClientServices();
67 #ifdef PLATFORM_WINDOWS
69 user_manager.GetUserList( user_list );
70 if ( user_list.Count() > 0 )
72 m_ClientServices = user_list.Get( 0 ).GetClientServices();
78 Error(
"BiosClientServices Error: Usermanager does not exist." );
99 if ( m_ClientServices )
101 m_ClientServices.GetLobbyService().GetServers( inputValues );
105 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
111 m_ClientServices.GetLobbyService().GetFavoriteServers(favServers);
116 m_ClientServices.GetLobbyService().GetCachedFavoriteServerInfo(favServersInfoCache);
119 static void SetServerFavorited(
string ipAddress,
int port,
int steamQueryPort,
bool is_favorited )
122 if ( m_ClientServices )
126 m_ClientServices.GetLobbyService().AddServerFavorite( ipAddress, port, steamQueryPort );
130 m_ClientServices.GetLobbyService().RemoveServerFavorite( ipAddress, port, steamQueryPort );
135 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
139 static void GetCurrentServerInfo(
string ip,
int port )
143 m_CurrentServerIP = ip;
144 m_CurrentServerPort = port;
148 inputValues.SetHostIp( ip );
149 inputValues.SetHostPort( port );
150 inputValues.m_Page = 0;
151 inputValues.m_RowsPerPage = 10;
152 inputValues.m_Platform = 1;
155 inputValues.m_Platform = 2;
158 inputValues.m_Platform = 3;
161 if ( m_ClientServices )
163 m_ClientServices.GetLobbyService().GetServers( inputValues );
167 static GetServersResultRow GetCurrentServerInfo()
169 if (m_CurrentServerInfo)
170 return m_CurrentServerInfo;
172 return g_Game.GetHostData();
175 static void ClearCurrentServerInfo()
177 m_CurrentServerInfo =
null;
178 m_CurrentServerIP =
"";
179 m_CurrentServerPort = 0;
182 static void SetInviteServerInfo(
string ip,
int port )
184 m_InviteServerIP = ip;
185 m_InviteServerPort = port;
188 static void GetInviteServerInfo( out
string ip, out
int port )
190 ip = m_InviteServerIP;
191 port = m_InviteServerPort;
196 if ( !ErrorCaught( error ) )
198 if ( m_CurrentServerIP !=
"" && m_CurrentServerPort > 0 )
200 foreach ( GetServersResultRow result : result_list.m_Results )
202 if ( result.m_HostIp == m_CurrentServerIP && result.m_HostPort == m_CurrentServerPort )
204 m_CurrentServerInfo = result;
205 m_CurrentServerIP =
"";
206 m_CurrentServerPort = 0;
225 m_ServersAsyncInvoker.Invoke( result_list, error, response );
229 m_ServersAsyncInvoker.Invoke(
null, error,
"" );
234 static void LoadFriends()
237 if ( m_ClientServices )
239 m_ClientServices.GetSocialService().GetFriendsAsync();
243 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
247 static void ShowUserProfile(
string uid )
250 if ( m_ClientServices )
252 m_ClientServices.GetSocialService().ShowUserProfileAsync( uid );
256 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
260 static void OnUserProfileAsync(
EBiosError error)
262 ErrorCaught( error );
267 if ( !ErrorCaught( error ) )
269 m_FriendsAsyncInvoker.Invoke( friend_list );
272 for (
int i = 0; i < friend_list.Count(); ++i )
274 string uid = friend_list[i].m_Uid;
282 friends_simple.Insert( newBfi.m_Uid );
284 m_FriendsList.Set( uid, newBfi );
288 m_FriendsList.Insert( uid, newBfi );
289 friends_simple.Insert( newBfi.m_Uid );
293 if ( !m_FirstFriendsLoad )
299 if ( m_FriendsList.Contains( player.m_UID ) )
304 ClientData.m_LastNewPlayers.m_PlayerList.Clear();
307 m_FirstFriendsLoad =
false;
314 if ( m_ClientServices )
319 ErrorCaught( m_ClientServices.GetPrivacyService().GetPermissionsAsync( player_list, perms ) );
323 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
329 if ( !ErrorCaught( error ) )
333 for (
int i = 0; i < result_list.Count(); i++ )
336 string uid = result.m_Uid;
339 if ( result_array && result_array2 )
343 new_list.Insert( result );
344 m_PermissionsList.Set( uid, result_array2 );
349 m_PermissionsList.Insert( uid, result_array2 );
350 new_list.Insert( result );
353 m_PermissionsAsyncInvoker.Invoke( new_list );
357 static bool IsPlayerMuted(
string id )
359 if ( m_MuteList.Contains(
id ) )
361 return m_MuteList.Get(
id );
366 static bool MutePlayer(
string id,
bool mute )
368 if ( m_MuteList.Contains(
id ) )
370 m_MuteList.Set(
id, mute );
374 m_MuteList.Insert(
id, mute );
392 static void ShowInviteScreen()
394 #ifdef PLATFORM_CONSOLE
396 if ( m_ClientServices )
400 if (
GetGame().GetHostAddress( addr, port ) )
402 ErrorCaught( m_ClientServices.GetSessionService().ShowInviteToGameplaySessionAsync( addr, port ) );
407 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
412 static void LoadMPPrivilege()
414 #ifdef PLATFORM_CONSOLE
416 if ( m_ClientServices )
418 ErrorCaught( m_ClientServices.GetPrivacyService().GetPrivilegeAsync(
EBiosPrivacyPrivilege.MULTIPLAYER_GAMEPLAY,
true ) );
422 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
429 static void LoadVoicePrivilege()
432 if ( m_ClientServices )
434 ErrorCaught( m_ClientServices.GetPrivacyService().GetPrivilegeAsync(
EBiosPrivacyPrivilege.COMMUNICATE_VOICE,
true ) );
438 DebugPrint.LogErrorAndTrace(
"BiosClientServices Error: Service reference does not exist." );
442 static void OnLoadMPPrivilege(
EBiosError err )
444 if ( !ErrorCaught( err ) )
450 if (
g_Game.GetGameState() != DayZGameState.MAIN_MENU )
456 g_Game.SetLoadState( DayZLoadState.MAIN_MENU_START );
462 static void OnLoadVoicePrivilege(
EBiosError err )
464 if (
g_Game.GetGameState() == DayZGameState.IN_GAME )
467 GetGame().GetWorld().DisableReceiveVoN( ErrorCaught( err ) );
469 GetGame().GetWorld().DisableTransmitVoN( ErrorCaught( err ) );
473 static void SetSessionHandle(
string handle )
476 if ( m_ClientServices )
478 m_ClientServices.GetSessionService().m_CurrentHandle = handle;
482 static string GetSessionHandle()
485 if ( m_ClientServices )
487 return m_ClientServices.GetSessionService().m_CurrentHandle;
492 static void GetSession()
495 if ( m_ClientServices )
497 m_ClientServices.GetSessionService().TryGetSession( GetSessionHandle() );
506 static void SetBiosUser(
BiosUser user)
512 static bool GetMultiplayState()
514 return m_MultiplayState;
517 static void SetMultiplayState(
bool state )
519 m_MultiplayState = state;
522 is_multiplay = state && (
ClientData.GetSimplePlayerList().Count() > 1 );
524 if ( m_ClientServices )
525 m_ClientServices.GetSessionService().SetMultiplayState(is_multiplay);
528 static void EnterGameplaySession()
532 if (
GetGame().GetHostAddress( addr, port ) )
535 if ( m_ClientServices )
537 m_ClientServices.GetSessionService().EnterGameplaySessionAsync( addr, port );
538 SetMultiplayState(
true);
543 static void LeaveGameplaySession()
546 if ( m_ClientServices )
548 GetServersResultRow currentServerInfo = GetCurrentServerInfo();
550 if ( currentServerInfo )
551 m_ClientServices.GetSessionService().LeaveGameplaySessionAsync(currentServerInfo.m_HostIp, currentServerInfo.m_HostPort);
552 else if ( m_CurrentServerIP !=
"" )
553 m_ClientServices.GetSessionService().LeaveGameplaySessionAsync(m_CurrentServerIP, m_CurrentServerPort);
555 SetMultiplayState(
false);
556 m_FirstFriendsLoad =
true;
559 m_FriendsList.Clear();
563 static void SetGameplayActivity()
567 if (
GetGame().GetHostAddress( addr, port ) )
570 if ( m_ClientServices )
572 m_ClientServices.GetSessionService().SetGameplayActivityAsync( addr, port );
581 if (
GetGame().GetHostAddress( addr, port ) )
584 if ( m_ClientServices )
586 m_PendingInvites = invitees;
587 m_ClientServices.GetSessionService().InviteToGameplaySessionAsync( addr, port, GetPendingInviteList() );
592 m_PendingInvites = invitees;
599 if ( already_on_server && m_PendingInvites )
602 foreach (
string invitee : m_PendingInvites )
604 if ( already_on_server.Find( invitee ) == -1 )
606 new_to_server.Insert( invitee );
609 return new_to_server;
613 return m_PendingInvites;
619 delete m_PendingInvites;
622 static int m_AutoConnectTries = 0;
623 static void AutoConnectToEmptyServer()
626 if ( m_ClientServices && m_AutoConnectTries == 0 )
628 m_AutoConnectTries = 1;
630 input.SetOfficial(
true );
631 m_ClientServices.GetLobbyService().GetFirstServerWithEmptySlot( input );
637 GetServersResultRow result;
640 if ( results && results.m_Result && results.m_Result.m_Results && results.m_Result.m_Results.Count() > 0 )
642 foreach ( GetServersResultRow result_temp : results.m_Result.m_Results )
644 if ( result_temp.m_FreeSlots > 0 )
646 results_free.Insert( result_temp );
651 return results_free.GetRandomElement();
656 if ( !ErrorCaught( error ) )
658 GetServersResultRow result = GetRandomFreeResult( result_list );
661 g_Game.ConnectFromServerBrowser( result.m_HostIp, result.m_HostPort );
662 m_AutoConnectTries = 0;
667 GetGame().GetUIManager().ShowDialog(
"#str_xbox_authentification_fail_title",
"#str_xbox_authentification_fail", 232, DBT_OK, DBB_NONE, DMT_INFO,
GetGame().GetUIManager().GetMenu() );
671 if ( m_AutoConnectTries < 3 )
673 m_AutoConnectTries++;
675 input.SetOfficial(
true );
676 m_ClientServices.GetLobbyService().GetFirstServerWithEmptySlot( input );
680 GetGame().GetUIManager().ShowDialog(
"#str_xbox_authentification_fail_title",
"#xbox_authentification_fail", 232, DBT_OK, DBB_NONE, DMT_INFO,
GetGame().GetUIManager().GetMenu() );
684 static void GetServerModList(
string server_id )
687 if ( m_ClientServices )
689 m_ClientServices.GetLobbyService().GetServerModList( server_id );
695 if ( !ErrorCaught( error ) )
697 m_ServerModLoadAsyncInvoker.Invoke( result_list );
701 static bool IsGameTrial(
bool sim )
704 #ifndef PLATFORM_WINDOWS
705 if ( m_TrialService )
706 return m_TrialService.IsGameTrial( sim );
712 static bool IsGameActive(
bool sim )
715 #ifndef PLATFORM_WINDOWS
716 if ( m_TrialService )
717 return m_TrialService.IsGameActive( sim );
723 static bool CheckUpdate()
726 if ( m_ClientServices )
728 EBiosError error = m_ClientServices.GetPackageService().CheckUpdateAsync();
739 static void PromptUpdate()
742 if ( m_ClientServices )
744 m_ClientServices.GetPackageService().PromptUpdateAsync();