🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectPlay8 Server encapsulation?

Started by
0 comments, last by wazoo69 22 years, 11 months ago
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
Learn about game programming!Games Programming in C++: Start to Finish
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

This topic is closed to new replies.

Advertisement