public static unsafe UInt32 PartyXblStartProcessingStateChanges(
            PARTY_XBL_HANDLE handle,
            out List <PARTY_XBL_STATE_CHANGE> stateChanges)
        {
            UInt32 err;

            stateChanges = null;
            if (handle == null)
            {
                return(PartyError.InvalidArg);
            }

            UInt32 stateChangeCount;
            IntPtr rawStateChanges;

            stateChanges = objectPool.Retrieve <List <PARTY_XBL_STATE_CHANGE> >();
            err          = PartyXblInterop.PartyXblStartProcessingStateChanges(handle.InteropHandle, out stateChangeCount, out rawStateChanges);
            if (PartyError.SUCCEEDED(err) && stateChangeCount > 0)
            {
                List <PARTY_XBL_STATE_CHANGE> unsupportStateChanges = null;
                IntPtr *arrayPtr = (IntPtr *)rawStateChanges.ToPointer();
                for (Int32 i = 0; i < stateChangeCount; i++)
                {
                    PARTY_XBL_STATE_CHANGE stateChangeObj = PARTY_XBL_STATE_CHANGE.CreateFromPtr(arrayPtr[i]);
                    if (stateChangeObj.GetType() != typeof(PARTY_XBL_STATE_CHANGE))
                    {
                        stateChanges.Add(stateChangeObj);
                    }
                    else
                    {
                        // Remove and immediately finish processing state changes that aren't supported by the
                        // CSharp wrapper, which will all be of the basic PARTY_STATE_CHANGE type
                        if (unsupportStateChanges == null)
                        {
                            unsupportStateChanges = objectPool.Retrieve <List <PARTY_XBL_STATE_CHANGE> >();
                        }

                        unsupportStateChanges.Add(stateChangeObj);
                    }
                }

                if (unsupportStateChanges != null)
                {
                    err = PartyXblFinishProcessingStateChanges(handle, unsupportStateChanges);
                }
            }

            return(err);
        }
Exemple #2
0
        internal static PARTY_XBL_STATE_CHANGE CreateFromPtr(IntPtr stateChangePtr)
        {
            PARTY_XBL_STATE_CHANGE       result           = null;
            PARTY_XBL_STATE_CHANGE_UNION stateChangeUnion = (PARTY_XBL_STATE_CHANGE_UNION)Marshal.PtrToStructure(stateChangePtr, typeof(PARTY_XBL_STATE_CHANGE_UNION));

            switch (stateChangeUnion.stateChange.stateChangeType)
            {
            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_TOKEN_AND_SIGNATURE_REQUESTED:
                result = new PARTY_XBL_TOKEN_AND_SIGNATURE_REQUESTED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_LOCAL_CHAT_USER_DESTROYED:
                result = new PARTY_XBL_LOCAL_CHAT_USER_DESTROYED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_CREATE_LOCAL_CHAT_USER_COMPLETED:
                result = new PARTY_XBL_CREATE_LOCAL_CHAT_USER_COMPLETED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_LOGIN_TO_PLAYFAB_COMPLETED:
                result = new PARTY_XBL_LOGIN_TO_PLAYFAB_COMPLETED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_GET_ENTITY_IDS_FROM_XBOX_LIVE_USER_IDS_COMPLETED:
                result = new PARTY_XBL_GET_ENTITY_IDS_FROM_XBOX_LIVE_USER_IDS_COMPLETED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            case PARTY_XBL_STATE_CHANGE_TYPE.PARTY_XBL_STATE_CHANGE_TYPE_REQUIRED_CHAT_PERMISSION_INFO_CHANGED:
                result = new PARTY_XBL_REQUIRED_CHAT_PERMISSION_INFO_CHANGED_STATE_CHANGE(stateChangeUnion, stateChangePtr);
                break;

            default:
                Debug.WriteLine(String.Format("Unhandle type {0}\n", stateChangeUnion.stateChange.stateChangeType));
                Debugger.Break();
                result = new PARTY_XBL_STATE_CHANGE(stateChangeUnion.stateChange.stateChangeType, stateChangePtr);
                break;
            }

            return(result);
        }