• Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectPlay8 Server encapsulation?

This topic is 6007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I''m trying to encapsulate the DirectPlay8Server object into a nice, easy to use class... My only problem is with the DirectPlayMessageHandler...I''ve declared that as static in the class definition file, but I''m still having trouble having *it* call other functions... (ie. when you receive an ADD_PLAYER message type, it should call the function, "addPlayer", etc)...it''s complaining about an illegal call of a non-static function from a static function.. But yet, if I make all of these functions static, then I lose some of my inherited class functions.. Any ideas?? thanks, Erik

Share this post


Link to post
Share on other sites
Advertisement
Alrighty, here's what you want to do:

      
class CSrv
{
public:
HRESULT Init();

private:
IDirectPlay8Serer *m_pDpSrv;

protected:
static HRESULT WINAPI SMsgHandler(PVOID pvThis, DWORD dwMsgType, PVOID pvMsg);
virtual HRESULT OnReceive(PDPNMSG_RECEIVE pdpMsg);
HRESULT SysHandler(DWORD dwMsgType, PVOID pvMsg);
};

HRESULT CSrv::Init()
{
CoInitialize(m_pDpSrv);
return m_pDpSrv->Initialize(this, SMsgHandler, 0);
}

HRESULT WINAPI CSrv::SMsgHandler(PVOID pvThis, DWORD dwMsgType, PVOID pvMsg)
{
CSrv *pSrv = (CSrv*)pvThis;
if(dwMsgType == DPN_MSGID_RECEIVE){
//USER MESSAGES

return pSrv->OnReceive((PDPNMSG_RECEIVE)pvMsg);
}else{
//SYSTEM MESSAGES

return pSrv->SysHandler(dwMsgType, pvMsg);
}
}

HRESULT CSrv::SysHandler(DWORD dwMsgType, PVOID pvMsg)
{
//DETERMINE SYSTEM MESSAGE TYPE AND HANDLE ACCORDINGLY

}


Edited by - JonStelly on August 7, 2001 11:08:23 PM

Edited by - JonStelly on August 7, 2001 11:09:40 PM

Share this post


Link to post
Share on other sites

  • Advertisement