File size: 8,004 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
class BiosSessionService
{
protected int m_GetSessionAttempts;
string m_CurrentHandle;
//! Enter a gameplay session
/*!
The async result is returned in the OnEnterGameplaySession callback.
Expected errors:
LOGICAL - if the user is currently in an active gameplay session.
@param session_address server IP address.
@param session_port server port.
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError EnterGameplaySessionAsync(string session_address, int session_port);
//! Leave a gameplay session
/*!
The async result is returned in the OnLeaveGameplaySession callback.
If there is an unexpected error the state is cleared.
Expected errors:
ERR_NOT_FOUND - when attempting to leave a gameplay session the user is not part of.
ERR_LOGICAL - when the user is not in a gameplay session.
@param session_address server IP address.
@param session_port server port.
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError LeaveGameplaySessionAsync(string session_address, int session_port);
//! Alerts engine that players in current session have changed
/*!
@param newPlayers players that have just joined the server. When player joins a server, ALL players already on server count as new players.
*/
proto native void OnSessionPlayerListUpdate(array<string> newPlayers);
//! Gets a session from a join handle
/*!
The async result is returned in the OnGetGameplaySession, OnGetLobbySession or OnGetSessionError callback,
dependinng on the type of session, or error.
Expected errors:
@param join_handle the parsed join handle.
@return EBiosError indicating if the async operation is pending.
*/
void TryGetSession( string join_handle = "" )
{
if ( join_handle != "" )
{
m_GetSessionAttempts = 0;
m_CurrentHandle = join_handle;
}
if ( m_GetSessionAttempts < 10 )
GetSessionAsync( m_CurrentHandle );
else
g_Game.DisconnectSessionEx(DISCONNECT_SESSION_FLAGS_JOIN);
}
//! Gets a session from a join handle
/*!
The async result is returned in the OnGetGameplaySession, OnGetLobbySession or OnGetSessionError callback,
dependinng on the type of session, or error.
Expected errors:
@param join_handle the parsed join handle.
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError GetSessionAsync(string join_handle);
//! Sets the activity to a gameplay session
/*!
The async result is returned in the OnSetActivity callback.
Expected errors:
ERR_NOT_FOUND - when attempting to set a gameplay session activity the user is not part of.
@param session_address server IP address.
@param session_port server port.
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError SetGameplayActivityAsync(string session_address, int session_port);
//! not implemented
//proto native EBiosError SetLobbyActivityAsync(...);
//! Clears the current activity
/*!
The async result is returned in the OnClearActivity callback.
Expected errors:
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError ClearActivityAsync();
//! Show system UI to invite friends to current gameplay session
/*!
The async result is returned in the OnShowInviteToGameplaySession callback.
On Xbox, if session with session_address and session_port does not exist, then xbox show
message "We could not send the invite".
@param session_address server IP address.
@param session_port server port.
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError ShowInviteToGameplaySessionAsync(string session_address, int session_port);
//! Send invite to list of users
/*!
The async result is returned in the OnInviteToGameplaySession callback.
The user must be inside the session. That means, OnEnterGameplaySession must be called with no errors.
@param session_address server IP address.
@param session_port server port.
@param invitee_list list of users to invite
@return EBiosError indicating if the async operation is pending.
*/
proto native EBiosError InviteToGameplaySessionAsync(string session_address, int session_port, array<string> invitee_list);
//! Notifiy about interactive multiplayer state
proto native void SetMultiplayState(bool is_active);
//! Callback function
/*!
@param error error indicating success or fail of the async operation.
*/
void OnSetActivity(EBiosError error)
{
OnlineServices.ErrorCaught( error );
}
//! Callback function
/*!
@param error error indicating success or fail of the async operation.
*/
void OnClearActivity(EBiosError error)
{
}
//! Callback function
/*!
@param session_address server IP address.
@param session_port server port.
*/
void OnGetGameplaySession(string session_address, int session_port)
{
m_GetSessionAttempts = 0;
switch (g_Game.GetGameState())
{
case DayZGameState.IN_GAME:
{
string addr;
int port;
bool found = GetGame().GetHostAddress( addr, port );
if (addr != session_address || port != session_port )
{
if (found)
{
OnlineServices.SetInviteServerInfo( session_address, session_port );
g_Game.GetUIManager().CloseAll();
if (!g_Game.GetUIManager().EnterScriptedMenu( MENU_INVITE_TIMER, null ))
{
NotificationSystem.AddNotification( NotificationType.CONNECT_FAIL_GENERIC, NotificationSystem.DEFAULT_TIME_DISPLAYED );
}
}
else
{
NotificationSystem.AddNotification( NotificationType.JOIN_FAIL_GET_SESSION, NotificationSystem.DEFAULT_TIME_DISPLAYED );
}
}
else
{
NotificationSystem.AddNotification( NotificationType.INVITE_FAIL_SAME_SERVER, NotificationSystem.DEFAULT_TIME_DISPLAYED, "#ps4_already_in_session" );
}
break;
}
case DayZGameState.CONNECTING:
{
g_Game.DisconnectSessionEx(DISCONNECT_SESSION_FLAGS_FORCE);
// Intentionally no break, fall through to connecting
}
default:
{
g_Game.ConnectFromJoin( session_address, session_port );
break;
}
}
}
//! //! Callback function, not implemented
/*void OnGetLobbySession(...)
{
}*/
//! Callback function
/*!
@param error error indicating fail of the async operation. Cannot be OK.
*/
void OnGetSessionError(EBiosError error)
{
OnlineServices.ErrorCaught( error );
m_GetSessionAttempts++;
#ifdef PLATFORM_XBOX
GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( TryGetSession, 100, false, "" );
#endif
#ifdef PLATFORM_PS4
g_Game.DisconnectSessionEx(DISCONNECT_SESSION_FLAGS_JOIN);
#endif
}
//! Callback function
/*!
@param session_address server IP address. Empty if failed.
@param session_port server port. 0 if failed.
@param error error indicating success or fail of the async operation.
*/
void OnEnterGameplaySession(string session_address, int session_port, EBiosError error)
{
if ( !OnlineServices.ErrorCaught( error ) )
{
SetGameplayActivityAsync( session_address, session_port );
if ( OnlineServices.GetPendingInviteList() )
InviteToGameplaySessionAsync( session_address, session_port, OnlineServices.GetPendingInviteList() );
//OnlineServices.GetCurrentServerInfo(session_address, session_port);
}
}
//! Callback function
/*!
@param error error indicating success or fail of the async operation.
*/
void OnLeaveGameplaySession(EBiosError error)
{
}
//! Callback function
/*!
@param error indicating success or fail of the async operation.
*/
void OnShowInviteToGameplaySession(EBiosError error)
{
OnlineServices.ErrorCaught( error );
}
//! Callback function
/*!
@param error indicating success or fail of the async operation.
*/
void OnInviteToGameplaySession(EBiosError error)
{
}
array<string> GetSessionPlayerList()
{
return ClientData.GetSimplePlayerList();
}
};
|