Lobby2Client.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_CLIENT_H
  11. #define __LOBBY_2_CLIENT_H
  12. #include "Lobby2Plugin.h"
  13. #include "DS_OrderedList.h"
  14. namespace RakNet
  15. {
  16. struct Lobby2Message;
  17. /// \brief Class used to send commands to Lobby2Server
  18. /// \details The lobby system works by sending implementations of Lobby2Message from Lobby2Client to Lobby2Server, and getting the results via Lobby2Client::SetCallbackInterface()<BR>
  19. /// The client itself is a thin shell that does little more than call Serialize on the messages.<BR>
  20. /// To use:<BR>
  21. /// <OL>
  22. /// <LI>Call Lobby2Client::SetServerAddress() after connecting to the system running Lobby2Server.
  23. /// <LI>Instantiate an instance of RakNet::Lobby2MessageFactory and register it with RakNet::Lobby2Plugin::SetMessageFactory() (the base class of Lobby2Client)
  24. /// <LI>Call messageFactory.Alloc(command); where command is one of the Lobby2MessageID enumerations.
  25. /// <LI>Instantiate a (probably derived) instance of Lobby2Callbacks and register it with Lobby2Client::SetCallbackInterface()
  26. /// <LI>Cast the returned structure, fill in the input parameters, and call Lobby2Client::SendMsg() to send this command to the server.
  27. /// <LI>Wait for the result of the operation to be sent to your callback. The message will contain the original input parameters, possibly output parameters, and Lobby2Message::resultCode will be filled in.
  28. /// </OL>
  29. /// \ingroup LOBBY_2_CLIENT
  30. class RAK_DLL_EXPORT Lobby2Client : public RakNet::Lobby2Plugin
  31. {
  32. public:
  33. Lobby2Client();
  34. virtual ~Lobby2Client();
  35. /// \brief Set the address of the server. When you call SendMsg() the packet will be sent to this address.
  36. void SetServerAddress(SystemAddress addr);
  37. // \brief Return whatever was passed to SetServerAddress()
  38. SystemAddress GetServerAddress(void) const;
  39. /// \brief Send a command to the server
  40. /// \param[in] msg The message that represents the command
  41. /// \param[in] callbackId Which callback, registered with SetCallbackInterface() or AddCallbackInterface(), should process the result. -1 for all
  42. virtual void SendMsg(Lobby2Message *msg);
  43. /// \brief Same as SendMsg()
  44. /// Also calls Dealloc on the message factory
  45. virtual void SendMsgAndDealloc(Lobby2Message *msg);
  46. // Let the user do this if they want. Not all users may want ignore lists
  47. /*
  48. /// For convenience, the list of ignored users is populated when Client_GetIgnoreList, Client_StopIgnore, and Client_StartIgnore complete.
  49. /// Client_GetIgnoreList is sent to us from the server automatically on login.
  50. /// The main reason this is here is so if you use RoomsPlugin as a client, you can check this list to filter out chat messages from ignored users.
  51. /// This is just a list of strings for you to read - it does NOT actually perform the ignore operation.
  52. virtual void AddToIgnoreList(RakNet::RakString user);
  53. virtual void RemoveFromIgnoreList(RakNet::RakString user);
  54. virtual void SetIgnoreList(DataStructures::List<RakNet::RakString> users);
  55. virtual bool IsInIgnoreList(RakNet::RakString user) const;
  56. void ClearIgnoreList(void);
  57. const DataStructures::OrderedList<RakNet::RakString, RakNet::RakString>* GetIgnoreList(void) const;
  58. DataStructures::OrderedList<RakNet::RakString, RakNet::RakString> ignoreList;
  59. */
  60. protected:
  61. PluginReceiveResult OnReceive(Packet *packet);
  62. void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
  63. void OnShutdown(void);
  64. void OnMessage(Packet *packet);
  65. SystemAddress serverAddress;
  66. Lobby2Callbacks *callback;
  67. };
  68. }
  69. #endif
粤ICP备19079148号