WOLQuickMatch.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * FILE
  21. * $Archive: /Commando/Code/Commando/WOLQuickMatch.h $
  22. *
  23. * DESCRIPTION
  24. *
  25. * PROGRAMMER
  26. * Denzil E. Long, Jr.
  27. * $Author: Denzil_l $
  28. *
  29. * VERSION INFO
  30. * $Revision: 18 $
  31. * $Modtime: 2/20/02 5:07p $
  32. *
  33. ******************************************************************************/
  34. #ifndef __WOLQUICKMATCH_H__
  35. #define __WOLQUICKMATCH_H__
  36. #include <WWLib\RefCount.h>
  37. #include <WWOnline\RefPtr.h>
  38. #include <WWOnline\WOLSession.h>
  39. #include <WWLib\Notify.h>
  40. class WaitCondition;
  41. class DlgWOLWaitEvent;
  42. class QuickMatchEvent :
  43. public TypedEvent<QuickMatchEvent, const WideStringClass>
  44. {
  45. public:
  46. enum Event {QMERROR = 0, QMINFO, QMMSG, QMMATCHED, QMUNKNOWN};
  47. Event GetEvent(void) const
  48. {return mEvent;}
  49. QuickMatchEvent(Event event, const WideStringClass& msg) :
  50. TypedEvent<QuickMatchEvent, const WideStringClass>(msg),
  51. mEvent(event)
  52. {}
  53. ~QuickMatchEvent()
  54. {}
  55. private:
  56. Event mEvent;
  57. };
  58. class WOLQuickMatch :
  59. public RefCountClass,
  60. public Notifier<QuickMatchEvent>,
  61. public Observer<WWOnline::ServerError>,
  62. public Observer<WWOnline::ChatMessage>
  63. {
  64. public:
  65. static WOLQuickMatch* Create(void);
  66. RefPtr<WaitCondition> ConnectClient(void);
  67. RefPtr<WaitCondition> Disconnect(void);
  68. bool SendClientInfo(void);
  69. void SendServerInfo(const char* exInfo, const char* topic);
  70. DECLARE_NOTIFIER(QuickMatchEvent)
  71. protected:
  72. WOLQuickMatch();
  73. ~WOLQuickMatch();
  74. bool FinalizeCreate(void);
  75. void SendStatus(const wchar_t* statusMsg);
  76. void ParseResponse(const wchar_t* message);
  77. void HandleNotification(WWOnline::ServerError&);
  78. void HandleNotification(WWOnline::ChatMessage&);
  79. private:
  80. // Prevent copy and assignment
  81. WOLQuickMatch(const WOLQuickMatch&);
  82. const WOLQuickMatch& operator=(const WOLQuickMatch&);
  83. static void ProcessInfo(WOLQuickMatch*, const wchar_t*);
  84. static void ProcessError(WOLQuickMatch*, const wchar_t*);
  85. static void ProcessStart(WOLQuickMatch*, const wchar_t*);
  86. static void ProcessUnknown(WOLQuickMatch*, const wchar_t*);
  87. protected:
  88. RefPtr<WWOnline::Session> mWOLSession;
  89. };
  90. #endif // __WOLQUICKMATCH_H__