aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Durango/Network/PartyController.h
blob: 621162ce889716ffc36238487b87d3e79b85cc6b (plain)
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
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once

#include <ppltasks.h>
class DQRNetworkManager;

class PartyController
{
public:
    PartyController(DQRNetworkManager *pDQRNet);

    void SetPartyView( Windows::Xbox::Multiplayer::PartyView^ partyView );
    Windows::Xbox::Multiplayer::PartyView^ GetPartyView();

    void RefreshPartyView();
    bool AddLocalUsersToParty(int userMask, Windows::Xbox::System::User^ primaryUser);
	void RemoveLocalUsersFromParty(Windows::Xbox::System::User^ primaryUser);
	void RemoveLocalUsersFromParty(Windows::Xbox::System::User^ primaryUser, int playerMask, Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ sessionReference);
	void RemoveLocalUserFromParty(Windows::Xbox::System::User^ userToRemove);
    void RegisterEventHandlers();
    void UnregisterEventHandlers();
    void UnregisterGamePlayersEventHandler();
    void RegisterGamePlayersChangedEventHandler();
    bool CanJoinParty();
    bool CanInvitePartyToMyGame( Microsoft::Xbox::Services::Multiplayer::MultiplayerSession^ multiplayerSession );
    bool IsPartyInAnotherTitle();
    bool IsGameSessionReadyEventTriggered();
    bool DoesPartySessionExist();
	Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference ^ GetGamePartySessionReference();
    void ClearGameSessionReadyEventTriggered();
    int GetActiveAndReservedMemberPartySize();
    bool DoesPartyAndSessionPlayersMatch(
        Microsoft::Xbox::Services::Multiplayer::MultiplayerSession^ session
        );
	void CheckPartySessionFull(Windows::Xbox::System::User^ primaryUser);
	void SetJoinability(bool isJoinable);
	void DisassociateSessionFromParty( Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ sessionReference);

private:
    Concurrency::critical_section m_lock;
    bool m_isGameSessionReadyEventTriggered;
    bool m_isGamePlayerEventRegistered;
	DQRNetworkManager *m_pDQRNet;

    static void DebugPrintPartyView( Windows::Xbox::Multiplayer::PartyView^ partyView );

    void OnPartyStateChanged( Windows::Xbox::Multiplayer::PartyStateChangedEventArgs^ eventArgs );
    void OnPartyRosterChanged( Windows::Xbox::Multiplayer::PartyRosterChangedEventArgs^ eventArgs );
    void OnGamePlayersChanged( Windows::Xbox::Multiplayer::GamePlayersChangedEventArgs^ eventArgs );
    void OnGameSessionReady( Windows::Xbox::Multiplayer::GameSessionReadyEventArgs^ eventArgs );
    Windows::Xbox::Multiplayer::PartyView^ m_partyView;
    Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ m_partyGameReadyRef;
    void AddAvailableGamePlayers(
        Windows::Foundation::Collections::IVectorView<Windows::Xbox::Multiplayer::GamePlayer^>^ availablePlayers, 
        int& remainingSlots, 
        Microsoft::Xbox::Services::Multiplayer::MultiplayerSession^ currentSession
        );

	Windows::Foundation::DateTime GetCurrentTime(); 
	double GetTimeBetweenInSeconds(Windows::Foundation::DateTime dt1, Windows::Foundation::DateTime dt2);

    // Party/Session events.
    Windows::Foundation::EventRegistrationToken m_partyRosterChangedToken;
    Windows::Foundation::EventRegistrationToken m_partyStateChangedToken;
    Windows::Foundation::EventRegistrationToken m_partyGamePlayersChangedToken;
    Windows::Foundation::EventRegistrationToken m_partyGameSessionReadyToken;
};