New thing for dplib: a base class for DPlay service providers. DPServiceProvider would be a wrapper around IDirectPlaySP, minus the Get- and SetSPData methods (which will be used to associate the DPServiceProvider to IDirectPlaySP instances internally).
Implement Service Provider callbacks as virtual methods in the subclass.
class MyServiceProvider: public dplib::DPServiceProvider {
private:
SomeProxiedConnection connection;
public:
virtual HRESULT Open (DPSP_OPENDATA* data) {
// Can use `this` to store stuff, instead of SetSPData and GetSPData.
this->connection.open("http://myproxy.com");
return DP_OK;
}
virtual HRESULT Send (DPSP_SENDDATA* data) {
this->connection.send(data->idPlayerTo, data->lpMessage, data->dwMessageSize);
return DP_OK;
}
};
Then, SPInit will be something like:
HRESULT WINAPI SPInit (SPINITDATA* data) {
auto sp = new MyServiceProvider(data);
return sp->init();
}
DPServiceProvider could also provide overloads for hooks. Eg, it could turn EnumSessions from EnumSessions (DPSP_ENUMSESSIONSDATA* data) into EnumSessions (void* message, int size, bool returnStatus).
And subclasses could choose to either use the simplified overloaded fn, or the raw DirectPlay-style struct parameter.
Likely methods:
EnumSessions
Reply
Send
CreatePlayer
DeletePlayer
GetAddress
GetCaps
Open
Close // actually DPlay's CloseEx hook
Shutdown // actually DPlay's ShutdownEx hook
GetAddressChoices
SendEx // could refer to the same Send() overload as Send() by default
SendToGroupEx // or just SendToGroup
Cancel
GetMessageQueue
DPlay's CloseEx and ShutdownEx would have to be used instead of its Close and Shutdown, because the standard Close and Shutdown hooks don't get the IDirectPlaySP interface passed in, so we couldn't use GetSPData to retrieve the DPServiceProvider instance.
New thing for dplib: a base class for DPlay service providers. DPServiceProvider would be a wrapper around IDirectPlaySP, minus the Get- and SetSPData methods (which will be used to associate the DPServiceProvider to IDirectPlaySP instances internally).
Implement Service Provider callbacks as virtual methods in the subclass.
Then,
SPInit
will be something like:DPServiceProvider could also provide overloads for hooks. Eg, it could turn EnumSessions from
EnumSessions (DPSP_ENUMSESSIONSDATA* data)
intoEnumSessions (void* message, int size, bool returnStatus)
.And subclasses could choose to either use the simplified overloaded fn, or the raw DirectPlay-style struct parameter.
Likely methods:
DPlay's CloseEx and ShutdownEx would have to be used instead of its Close and Shutdown, because the standard Close and Shutdown hooks don't get the IDirectPlaySP interface passed in, so we couldn't use GetSPData to retrieve the DPServiceProvider instance.