public void CompleteGetXToken(int hresult, XUserGetTokenAndSignatureUtf16Data tokenData) { PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:CompleteGetXToken(), hr: " + hresult); if (hresult >= 0) { Get().Succeeded(XBLSDK.PartyXblCompleteGetTokenAndSignatureRequest( Get()._xblPartyHandle, correlationId, true, tokenData.Token, tokenData.Signature )); } else if (hresult == _E_GAMEUSER_RESOLVE_USER_ISSUE_REQUIRED) { // We need to resolve #if (MICROSOFT_GAME_CORE || UNITY_GAMECORE) XGamingRuntime.SDK.XUserResolveIssueWithUiUtf16Async( Get()._xblLocalUserHandle, url, _ResolveUserIssueWithUICompleted ); #endif } else { PlayFabMultiplayerManager._LogError(_ErrorMessageCouldNotGetXboxLiveToken); } }
private void TryCreateRemoteXboxLiveChatUser(PlayFabPlayer otherPlayer) { if (string.IsNullOrEmpty(otherPlayer._platformSpecificUserId)) { _queuedCreateRemoteXboxLiveChatUserOps.Add(new QueuedCreateRemoteXboxLiveChatUserOp() { otherPlayer = otherPlayer }); return; } ulong xuid = Convert.ToUInt64(otherPlayer._platformSpecificUserId); PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:TryCreateRemoteXboxLiveChatUser(), XUID: " + xuid); if (Succeeded(XBLSDK.PartyXblCreateRemoteChatUser( _xblPartyHandle, xuid, out otherPlayer._xblChatUserHandle ))) { for (int i = 0; i < _queuedCreateRemoteXboxLiveChatUserOps.Count; i++) { if (xuid == _queuedCreateRemoteXboxLiveChatUserOps[i].xuid) { _queuedCreateRemoteXboxLiveChatUserOps.RemoveAt(i); break; } } } }
private void UpdateChatPermissionInfoComplete(PARTY_XBL_CHAT_USER_HANDLE localXblChatUser, PARTY_XBL_CHAT_USER_HANDLE targetXblChatUser) { PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:UpdateChatPermissionInfoComplete()"); ulong localXuid; ulong targetXuid; if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(localXblChatUser, out localXuid))) { return; } if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(targetXblChatUser, out targetXuid))) { return; } PlayFabPlayer localPlayer = GetPlayerByXuid(localXuid); PlayFabPlayer targetPlayer = GetPlayerByXuid(targetXuid); PARTY_XBL_CHAT_PERMISSION_INFO chatPermissionInfo; Succeeded(XBLSDK.PartyXblLocalChatUserGetRequiredChatPermissionInfo( localXblChatUser, targetXblChatUser, out chatPermissionInfo )); Succeeded(PartyCSharpSDK.SDK.PartyChatControlSetPermissions( localPlayer._chatControlHandle, targetPlayer._chatControlHandle, chatPermissionInfo.ChatPermissionMask )); var permissionsQuery = chatPermissionInfo.ChatPermissionMask; if (permissionsQuery != _CHAT_PERMISSIONS_ALL) { foreach (var playerKeyPair in _multiplayerManager.RemotePlayers) { if (playerKeyPair.EntityKey.Id == targetPlayer.EntityKey.Id) { playerKeyPair._mutedByPlatform = true; playerKeyPair.IsMuted = true; break; } } } if (!_playerChatPermissions.ContainsKey(targetPlayer)) { _playerChatPermissions.Add(targetPlayer, chatPermissionInfo); } }
public PlayFabChatXboxLivePolicyProvider() { PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:PlayFabChatXboxLivePolicyProvider()"); _multiplayerManager = PlayFabMultiplayerManager.Get(); string titleId = PlayFabSettings.staticSettings.TitleId; _playerChatPermissions = new Dictionary <PlayFabPlayer, PARTY_XBL_CHAT_PERMISSION_INFO>(new PlayerComparator()); _queuedCreateRemoteXboxLiveChatUserOps = new List <QueuedCreateRemoteXboxLiveChatUserOp>(); _xblStateChanges = new List <PARTY_XBL_STATE_CHANGE>(); _internalXuidExchangeMessageBuffer = new byte[_INTERNAL_XUID_EXCHANGE_MESSAGE_BUFFER_SIZE]; Succeeded(XBLSDK.PartyXblInitialize(titleId, out _xblPartyHandle)); _XUID_EXCHANGE_REQUEST_AS_BYTES = Encoding.ASCII.GetBytes(_XUID_EXCHANGE_REQUEST_MESSAGE_PREFIX); _XUID_EXCHANGE_RESPONSE_AS_BYTES = Encoding.ASCII.GetBytes(_XUID_EXCHANGE_RESPONSE_MESSAGE_PREFIX); }
public bool IsTextToSpeechEnabled() { bool isTextToSpeechEnabled = false; PARTY_XBL_ACCESSIBILITY_SETTINGS accessibilitySettings; Succeeded(XBLSDK.PartyXblLocalChatUserGetAccessibilitySettings( _xblLocalChatUserHandle, out accessibilitySettings )); if (accessibilitySettings != null && accessibilitySettings.TextToSpeechEnabled != 0) { isTextToSpeechEnabled = true; } PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:IsTextToSpeechEnabled(), value: " + isTextToSpeechEnabled); return(isTextToSpeechEnabled); }
public PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS GetPlatformUserChatTranscriptionPreferences() { PARTY_XBL_ACCESSIBILITY_SETTINGS accessibilitySettings; PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS partyChatTranscriptionOptions = PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS.PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS_NONE; Succeeded(XBLSDK.PartyXblLocalChatUserGetAccessibilitySettings( _xblLocalChatUserHandle, out accessibilitySettings )); if (accessibilitySettings != null && accessibilitySettings.SpeechToTextEnabled != 0) { partyChatTranscriptionOptions = PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS.PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS_TRANSCRIBE_OTHER_CHAT_CONTROLS_WITH_MATCHING_LANGUAGES | PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS.PARTY_VOICE_CHAT_TRANSCRIPTION_OPTIONS_TRANSCRIBE_SELF; } PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:GetPlatformUserChatTranscriptionPreferences(), transcription options: " + partyChatTranscriptionOptions); return(partyChatTranscriptionOptions); }
public bool CleanUp() { PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:CleanUp()"); bool succeeded = true; succeeded = Succeeded(XBLSDK.PartyXblCleanup(_xblPartyHandle)); _xblPolicyProvider = null; _playerChatPermissions = null; _xblStateChanges = null; _queuedCreateRemoteXboxLiveChatUserOps = null; _internalXuidExchangeMessageBuffer = null; _XUID_EXCHANGE_REQUEST_AS_BYTES = null; _XUID_EXCHANGE_RESPONSE_AS_BYTES = null; _xblLocalChatUserHandle = null; _xblPartyHandle = null; return(succeeded); }
private void SignInSilentlyComplete(int hresult, XUserHandle userHandle) { if (HrSucceeded(hresult)) { _xblLocalUserHandle = userHandle; } else { PlayFabMultiplayerManager._LogError(_ErrorMessageXboxLiveSignInFailed); } ulong xuid; int hr = 0; #if (MICROSOFT_GAME_CORE || UNITY_GAMECORE) hr = XGamingRuntime.SDK.XUserGetId(_xblLocalUserHandle, out xuid); #endif PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:SignInSilentlyComplete(), XUID: " + xuid); if (HrSucceeded(hresult)) { if (_xblLocalChatUserHandle == null) { Succeeded(XBLSDK.PartyXblCreateLocalChatUser( _xblPartyHandle, xuid, null, out _xblLocalChatUserHandle )); } Succeeded(XBLSDK.PartyXblLoginToPlayFab( _xblLocalChatUserHandle, null )); } else { PlayFabMultiplayerManager._LogError(_ErrorMessageCouldNotGetXuid); } }
private bool IsReadyToSetChatPermissions(PARTY_XBL_CHAT_USER_HANDLE localXblChatUser, PARTY_XBL_CHAT_USER_HANDLE targetXblChatUser) { bool isReadyToSetChatPermissions = false; ulong localXuid; ulong targetXuid; if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(localXblChatUser, out localXuid))) { return(false); } if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(targetXblChatUser, out targetXuid))) { return(false); } isReadyToSetChatPermissions = GetPlayerByXuid(localXuid) != null && GetPlayerByXuid(targetXuid) != null; return(isReadyToSetChatPermissions); }
private void UpdateChatPermissionInfoComplete(PARTY_XBL_CHAT_USER_HANDLE localXblChatUser, PARTY_XBL_CHAT_USER_HANDLE targetXblChatUser) { PlayFabMultiplayerManager._LogInfo("PlayFabChatXboxLivePolicyProvider:UpdateChatPermissionInfoComplete()"); // UpdateChatPermissionInfoComplete() is called when we are finally ready to set permissions, // and thus the cached operation in _queuedUpdateChatPermissionsOp is no longer needed // (if it was created then localXblChatUser and targetXblChatUser from it will be used in this method // to set permissions). It needs to be reset to prevent unnecessary continuous re-entrance to this method. if (_queuedUpdateChatPermissionsOp.queued) { _queuedUpdateChatPermissionsOp = new QueuedUpdateChatPermissionsOp(); // reset _queuedUpdateChatPermissionsOp to its initial (default) state } ulong localXuid; ulong targetXuid; if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(localXblChatUser, out localXuid))) { return; } if (!Succeeded(XBLSDK.PartyXblChatUserGetXboxUserId(targetXblChatUser, out targetXuid))) { return; } PlayFabPlayer localPlayer = GetPlayerByXuid(localXuid); PlayFabPlayer targetPlayer = GetPlayerByXuid(targetXuid); if (localPlayer == null || targetPlayer == null) { return; } PARTY_XBL_CHAT_PERMISSION_INFO chatPermissionInfo; Succeeded(XBLSDK.PartyXblLocalChatUserGetRequiredChatPermissionInfo( localXblChatUser, targetXblChatUser, out chatPermissionInfo )); Succeeded(PartyCSharpSDK.SDK.PartyChatControlSetPermissions( localPlayer._chatControlHandle, targetPlayer._chatControlHandle, chatPermissionInfo.ChatPermissionMask )); var permissionsQuery = chatPermissionInfo.ChatPermissionMask; if (permissionsQuery != _CHAT_PERMISSIONS_ALL) { foreach (var playerKeyPair in _multiplayerManager.RemotePlayers) { if (playerKeyPair.EntityKey.Id == targetPlayer.EntityKey.Id) { playerKeyPair._mutedByPlatform = true; playerKeyPair.IsMuted = true; break; } } } if (!_playerChatPermissions.ContainsKey(targetPlayer)) { _playerChatPermissions.Add(targetPlayer, chatPermissionInfo); } }
public void ProcessStateChanges() { if (Succeeded(XBLSDK.PartyXblStartProcessingStateChanges(_xblPartyHandle, out _xblStateChanges))) { foreach (PARTY_XBL_STATE_CHANGE stateChange in _xblStateChanges) { PlayFabMultiplayerManager._LogInfo("XBL State change: " + stateChange.StateChangeType.ToString()); switch (stateChange.StateChangeType) { case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_TOKEN_AND_SIGNATURE_REQUESTED: { var stateChangeConverted = (PARTY_XBL_TOKEN_AND_SIGNATURE_REQUESTED_STATE_CHANGE)stateChange; TrackableGetXTokenCompletedWrapper trackableGetXTokenCompletedWrapper = new TrackableGetXTokenCompletedWrapper(); trackableGetXTokenCompletedWrapper.correlationId = stateChangeConverted.correlationId; trackableGetXTokenCompletedWrapper.url = stateChangeConverted.url; trackableGetXTokenCompletedWrapper.method = stateChangeConverted.method; trackableGetXTokenCompletedWrapper.headers = stateChangeConverted.headers; trackableGetXTokenCompletedWrapper.body = stateChangeConverted.body; XUserGetTokenAndSignatureOptions options = XUserGetTokenAndSignatureOptions.None; if (stateChangeConverted.allUsers) { options |= XUserGetTokenAndSignatureOptions.AllUsers; } if (stateChangeConverted.forceRefresh) { options |= XUserGetTokenAndSignatureOptions.ForceRefresh; } XUserGetTokenAndSignatureUtf16HttpHeader[] tokenRequestHeaders = new XUserGetTokenAndSignatureUtf16HttpHeader[stateChangeConverted.headers.Length]; for (uint i = 0; i < stateChangeConverted.headers.Length; i++) { string tokenRequestHeaderName = stateChangeConverted.headers[i].name; string tokenRequestHeaderValue = stateChangeConverted.headers[i].value; tokenRequestHeaders[i] = new XUserGetTokenAndSignatureUtf16HttpHeader(tokenRequestHeaderName, tokenRequestHeaderValue); } var headers = tokenRequestHeaders; if (stateChangeConverted.headers.Length == 0) { headers = null; } var body = stateChangeConverted.body; if (stateChangeConverted.body.Length == 0) { body = null; } #if (MICROSOFT_GAME_CORE || UNITY_GAMECORE) XGamingRuntime.SDK.XUserGetTokenAndSignatureUtf16Async( _xblLocalUserHandle, options, stateChangeConverted.method, stateChangeConverted.url, headers, body, trackableGetXTokenCompletedWrapper.CompleteGetXToken ); #endif break; } case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_CREATE_LOCAL_CHAT_USER_COMPLETED: { var stateChangeConverted = (PARTY_XBL_CREATE_LOCAL_CHAT_USER_COMPLETED_STATE_CHANGE)stateChange; _multiplayerManager.InternalCheckStateChangeSucceededOrLogErrorIfFailed(stateChangeConverted.result, stateChangeConverted.errorDetail); break; } case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_LOGIN_TO_PLAYFAB_COMPLETED: { var stateChangeConverted = (PARTY_XBL_LOGIN_TO_PLAYFAB_COMPLETED_STATE_CHANGE)stateChange; if (_multiplayerManager.InternalCheckStateChangeSucceededOrLogErrorIfFailed(stateChangeConverted.result, stateChangeConverted.errorDetail)) { OnPlayFabLoginSuccess(stateChangeConverted); } break; } case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_LOCAL_CHAT_USER_DESTROYED: break; case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_REQUIRED_CHAT_PERMISSION_INFO_CHANGED: { var stateChangeConverted = (PARTY_XBL_REQUIRED_CHAT_PERMISSION_INFO_CHANGED_STATE_CHANGE)stateChange; PARTY_XBL_CHAT_USER_HANDLE localXblChatUser = stateChangeConverted.localChatUser; PARTY_XBL_CHAT_USER_HANDLE targetXblChatUser = stateChangeConverted.targetChatUser; UpdateChatPermissionInfoStart(localXblChatUser, targetXblChatUser); } break; default: break; } } Succeeded(XBLSDK.PartyXblFinishProcessingStateChanges(_xblPartyHandle, _xblStateChanges)); } }