mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-03 23:28:48 +00:00 
			
		
		
		
	HLE/Services: Allow specifying a SessionData template parameter to ServiceFramework.
Some services can have multiple clients at the same time, and they identify the different clients using the server session as a key. This parameter (if present) should be a structure that contains the per-session data for each service. The data can be retrieved using ServiceFramework::GetSessionData(session)
This commit is contained in:
		
							parent
							
								
									aecd2b85fe
								
							
						
					
					
						commit
						daecd812b0
					
				
					 4 changed files with 57 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -108,6 +108,10 @@ public:
 | 
			
		|||
 | 
			
		||||
protected:
 | 
			
		||||
    void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
 | 
			
		||||
 | 
			
		||||
    std::unique_ptr<SessionDataBase> MakeSessionData() const override {
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -87,6 +87,10 @@ public:
 | 
			
		|||
protected:
 | 
			
		||||
    void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
 | 
			
		||||
 | 
			
		||||
    std::unique_ptr<SessionDataBase> MakeSessionData() const override {
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Registers the functions in the service
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +148,7 @@ protected:
 | 
			
		|||
    using HandlerFnP = void (Self::*)(Kernel::HLERequestContext&);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    template <typename T, typename SessionData>
 | 
			
		||||
    friend class ServiceFramework;
 | 
			
		||||
 | 
			
		||||
    struct FunctionInfoBase {
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +194,7 @@ private:
 | 
			
		|||
 * of the passed in function pointers and then delegate the actual work to the implementation in the
 | 
			
		||||
 * base class.
 | 
			
		||||
 */
 | 
			
		||||
template <typename Self>
 | 
			
		||||
template <typename Self, typename SessionData = Kernel::SessionRequestHandler::SessionDataBase>
 | 
			
		||||
class ServiceFramework : public ServiceFrameworkBase {
 | 
			
		||||
protected:
 | 
			
		||||
    /// Contains information about a request type which is handled by the service.
 | 
			
		||||
| 
						 | 
				
			
			@ -236,6 +240,14 @@ protected:
 | 
			
		|||
        RegisterHandlersBase(functions, n);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::unique_ptr<SessionDataBase> MakeSessionData() const override {
 | 
			
		||||
        return std::make_unique<SessionData>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SessionData* GetSessionData(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
 | 
			
		||||
        return ServiceFrameworkBase::GetSessionData<SessionData>(server_session);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    /**
 | 
			
		||||
     * This function is used to allow invocation of pointers to handlers stored in the base class
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue