Lobby2Message_Steam.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __LOBBY_2_MESSAGE_STEAM_H
  11. #define __LOBBY_2_MESSAGE_STEAM_H
  12. #include "Lobby2Message.h"
  13. #include "DS_Multilist.h"
  14. #include "Lobby2Client_Steam.h"
  15. namespace RakNet
  16. {
  17. #define __L2_MSG_DB_HEADER(__NAME__,__DB__) \
  18. struct __NAME__##_##__DB__ : public __NAME__
  19. __L2_MSG_DB_HEADER(Client_Login, Steam)
  20. {
  21. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  22. virtual void DebugMsg(RakNet::RakString &out) const
  23. {
  24. if (resultCode!=L2RC_SUCCESS)
  25. {
  26. Client_Login::DebugMsg(out);
  27. return;
  28. }
  29. out.Set("Login success");
  30. }
  31. };
  32. __L2_MSG_DB_HEADER(Client_Logoff, Steam)
  33. {
  34. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  35. virtual void DebugMsg(RakNet::RakString &out) const
  36. {
  37. if (resultCode!=L2RC_SUCCESS)
  38. {
  39. Client_Logoff::DebugMsg(out);
  40. return;
  41. }
  42. out.Set("Logoff success");
  43. }
  44. };
  45. __L2_MSG_DB_HEADER(Console_SearchRooms, Steam)
  46. {
  47. Console_SearchRooms_Steam();
  48. virtual ~Console_SearchRooms_Steam();
  49. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  50. virtual void DebugMsg(RakNet::RakString &out) const;
  51. // Output
  52. // Use CConsoleCommand_GetRoomDetails to get room names for unknown rooms, which will have blank names
  53. DataStructures::Multilist<ML_UNORDERED_LIST, RakNet::RakString> roomNames;
  54. // Type of uint64_ts is uint64_t
  55. DataStructures::Multilist<ML_UNORDERED_LIST, uint64_t> roomIds;
  56. /// \internal
  57. // uint32_t is LobbyMatchList_t
  58. // CCallResult<Lobby2Client_Steam, uint32_t> m_SteamCallResultLobbyMatchList;
  59. void *m_SteamCallResultLobbyMatchList;
  60. };
  61. __L2_MSG_DB_HEADER(Console_GetRoomDetails, Steam)
  62. {
  63. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  64. virtual void DebugMsg(RakNet::RakString &out) const
  65. {
  66. if (resultCode!=L2RC_SUCCESS)
  67. {
  68. Console_GetRoomDetails::DebugMsg(out);
  69. return;
  70. }
  71. out.Set("GetRoomDetails: roomName=%s for id %" PRINTF_64_BIT_MODIFIER "u", roomName.C_String(), roomId);
  72. }
  73. /// Input
  74. uint64_t roomId;
  75. /// Output
  76. RakNet::RakString roomName;
  77. };
  78. __L2_MSG_DB_HEADER(Console_CreateRoom, Steam)
  79. {
  80. Console_CreateRoom_Steam();
  81. virtual ~Console_CreateRoom_Steam();
  82. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  83. virtual void DebugMsg(RakNet::RakString &out) const
  84. {
  85. if (resultCode!=L2RC_SUCCESS)
  86. {
  87. Console_CreateRoom::DebugMsg(out);
  88. return;
  89. }
  90. out.Set("Console_CreateRoom: roomName %s created for id %" PRINTF_64_BIT_MODIFIER "u", roomName.C_String(), roomId);
  91. }
  92. /// Input
  93. /// If public, anyone can join. Else friends only
  94. bool roomIsPublic;
  95. RakNet::RakString roomName;
  96. /// Output
  97. uint64_t roomId;
  98. /// \internal
  99. // CCallResult<Lobby2Client_Steam, LobbyCreated_t> m_SteamCallResultLobbyCreated;
  100. void *m_SteamCallResultLobbyCreated;
  101. };
  102. __L2_MSG_DB_HEADER(Console_JoinRoom, Steam)
  103. {
  104. Console_JoinRoom_Steam();
  105. virtual ~Console_JoinRoom_Steam();
  106. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  107. virtual void DebugMsg(RakNet::RakString &out) const
  108. {
  109. if (resultCode!=L2RC_SUCCESS)
  110. {
  111. Console_JoinRoom::DebugMsg(out);
  112. return;
  113. }
  114. out.Set("Console_JoinRoom: Joined id %" PRINTF_64_BIT_MODIFIER "u", roomId);
  115. }
  116. /// Input
  117. uint64_t roomId;
  118. /// \internal
  119. //CCallResult<Lobby2Client_Steam, LobbyEnter_t> m_SteamCallResultLobbyEntered;
  120. void *m_SteamCallResultLobbyEntered;
  121. };
  122. __L2_MSG_DB_HEADER(Console_LeaveRoom, Steam)
  123. {
  124. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  125. virtual void DebugMsg(RakNet::RakString &out) const
  126. {
  127. if (resultCode!=L2RC_SUCCESS)
  128. {
  129. Console_LeaveRoom::DebugMsg(out);
  130. return;
  131. }
  132. out.Set("Left room %" PRINTF_64_BIT_MODIFIER "u", roomId);
  133. }
  134. /// Input
  135. uint64_t roomId;
  136. };
  137. __L2_MSG_DB_HEADER(Console_SendRoomChatMessage, Steam)
  138. {
  139. virtual bool ClientImpl( RakNet::Lobby2Plugin *client);
  140. virtual void DebugMsg(RakNet::RakString &out) const
  141. {
  142. if (resultCode!=L2RC_SUCCESS)
  143. {
  144. Console_SendRoomChatMessage::DebugMsg(out);
  145. return;
  146. }
  147. out.Set("Sent %s to room %" PRINTF_64_BIT_MODIFIER "u", message.C_String(), roomId);
  148. }
  149. /// Input
  150. uint64_t roomId;
  151. RakNet::RakString message;
  152. };
  153. __L2_MSG_DB_HEADER(Notification_Friends_StatusChange, Steam)
  154. {
  155. uint64_t friendId;
  156. RakNet::RakString friendNewName;
  157. virtual void DebugMsg(RakNet::RakString &out) const
  158. {
  159. if (resultCode!=L2RC_SUCCESS)
  160. {
  161. Notification_Friends_StatusChange::DebugMsg(out);
  162. return;
  163. }
  164. out.Set("Friend renamed to %s with ID %" PRINTF_64_BIT_MODIFIER "u", friendNewName.C_String(), friendId);
  165. }
  166. };
  167. __L2_MSG_DB_HEADER(Notification_Console_UpdateRoomParameters, Steam)
  168. {
  169. uint64_t roomId;
  170. RakNet::RakString roomNewName;
  171. virtual void DebugMsg(RakNet::RakString &out) const
  172. {
  173. if (resultCode!=L2RC_SUCCESS)
  174. {
  175. Notification_Console_UpdateRoomParameters::DebugMsg(out);
  176. return;
  177. }
  178. out.Set("RoomStateChanged: Room named %s with ID %" PRINTF_64_BIT_MODIFIER "u", roomNewName.C_String(), roomId);
  179. }
  180. };
  181. __L2_MSG_DB_HEADER(Notification_Console_MemberJoinedRoom, Steam)
  182. {
  183. uint64_t roomId;
  184. uint64_t srcMemberId;
  185. RakNet::RakString memberName;
  186. SystemAddress remoteSystem;
  187. virtual void DebugMsg(RakNet::RakString &out) const
  188. {
  189. if (resultCode!=L2RC_SUCCESS)
  190. {
  191. Notification_Console_MemberJoinedRoom::DebugMsg(out);
  192. return;
  193. }
  194. out.Set("MemberJoinedRoom: Member named %s and ID %" PRINTF_64_BIT_MODIFIER "u joined room with ID %" PRINTF_64_BIT_MODIFIER "u", memberName.C_String(), srcMemberId, roomId);
  195. }
  196. };
  197. __L2_MSG_DB_HEADER(Notification_Console_MemberLeftRoom, Steam)
  198. {
  199. uint64_t roomId;
  200. uint64_t srcMemberId;
  201. RakNet::RakString memberName;
  202. SystemAddress remoteSystem;
  203. virtual void DebugMsg(RakNet::RakString &out) const
  204. {
  205. if (resultCode!=L2RC_SUCCESS)
  206. {
  207. Notification_Console_MemberLeftRoom::DebugMsg(out);
  208. return;
  209. }
  210. out.Set("MemberLeftRoom: Member named %s and ID %" PRINTF_64_BIT_MODIFIER "u left room with ID %" PRINTF_64_BIT_MODIFIER "u", memberName.C_String(), srcMemberId, roomId);
  211. }
  212. };
  213. __L2_MSG_DB_HEADER(Notification_Console_RoomChatMessage, Steam)
  214. {
  215. RakNet::RakString message;
  216. virtual void DebugMsg(RakNet::RakString &out) const
  217. {
  218. if (resultCode!=L2RC_SUCCESS)
  219. {
  220. Notification_Console_RoomChatMessage::DebugMsg(out);
  221. return;
  222. }
  223. out=message;
  224. }
  225. };
  226. /*
  227. __L2_MSG_DB_HEADER(Notification_Console_RoomMemberConnectivityUpdate, Steam)
  228. {
  229. bool succeeded;
  230. SystemAddress remoteSystem;
  231. virtual void DebugMsg(RakNet::RakString &out) const
  232. {
  233. if (resultCode!=L2RC_SUCCESS)
  234. {
  235. Notification_Console_RoomMemberConnectivityUpdate::DebugMsg(out);
  236. return;
  237. }
  238. if (succeeded)
  239. {
  240. out.Set("Signaling to %s succeeded.", remoteSystem.ToString(true));
  241. }
  242. else
  243. {
  244. out.Set("Signaling to %s failed.", remoteSystem.ToString(true));
  245. }
  246. }
  247. };
  248. */
  249. // --------------------------------------------- Database specific factory class for all messages --------------------------------------------
  250. #define __L2_MSG_FACTORY_IMPL(__NAME__,__DB__) {case L2MID_##__NAME__ : Lobby2Message *m = RakNet::OP_NEW< __NAME__##_##__DB__ >(_FILE_AND_LINE_) ; return m;}
  251. struct Lobby2MessageFactory_Steam : public Lobby2MessageFactory
  252. {
  253. Lobby2MessageFactory_Steam() {}
  254. virtual ~Lobby2MessageFactory_Steam() {}
  255. virtual Lobby2Message *Alloc(Lobby2MessageID id)
  256. {
  257. switch (id)
  258. {
  259. __L2_MSG_FACTORY_IMPL(Client_Login, Steam);
  260. __L2_MSG_FACTORY_IMPL(Client_Logoff, Steam);
  261. __L2_MSG_FACTORY_IMPL(Console_SearchRooms, Steam);
  262. __L2_MSG_FACTORY_IMPL(Console_GetRoomDetails, Steam);
  263. __L2_MSG_FACTORY_IMPL(Console_CreateRoom, Steam);
  264. __L2_MSG_FACTORY_IMPL(Console_JoinRoom, Steam);
  265. __L2_MSG_FACTORY_IMPL(Console_LeaveRoom, Steam);
  266. __L2_MSG_FACTORY_IMPL(Console_SendRoomChatMessage, Steam);
  267. __L2_MSG_FACTORY_IMPL(Notification_Friends_StatusChange, Steam);
  268. __L2_MSG_FACTORY_IMPL(Notification_Console_UpdateRoomParameters, Steam);
  269. __L2_MSG_FACTORY_IMPL(Notification_Console_MemberJoinedRoom, Steam);
  270. __L2_MSG_FACTORY_IMPL(Notification_Console_MemberLeftRoom, Steam);
  271. __L2_MSG_FACTORY_IMPL(Notification_Console_RoomChatMessage, Steam);
  272. //__L2_MSG_FACTORY_IMPL(Notification_Console_RoomMemberConnectivityUpdate, Steam);
  273. default:
  274. return Lobby2MessageFactory::Alloc(id);
  275. };
  276. };
  277. };
  278. }; // namespace RakNet
  279. #endif
粤ICP备19079148号