RakNetCommandParser.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /// \file
  11. /// \brief Contains RakNetCommandParser , used to send commands to an instance of RakPeer
  12. ///
  13. #include "NativeFeatureIncludes.h"
  14. #if _RAKNET_SUPPORT_RakNetCommandParser==1
  15. #ifndef __RAKNET_COMMAND_PARSER
  16. #define __RAKNET_COMMAND_PARSER
  17. #include "CommandParserInterface.h"
  18. #include "Export.h"
  19. namespace RakNet
  20. {
  21. class RakPeerInterface;
  22. /// \brief This allows a console client to call most of the functions in RakPeer
  23. class RAK_DLL_EXPORT RakNetCommandParser : public CommandParserInterface
  24. {
  25. public:
  26. // GetInstance() and DestroyInstance(instance*)
  27. STATIC_FACTORY_DECLARATIONS(RakNetCommandParser)
  28. RakNetCommandParser();
  29. ~RakNetCommandParser();
  30. /// Given \a command with parameters \a parameterList , do whatever processing you wish.
  31. /// \param[in] command The command to process
  32. /// \param[in] numParameters How many parameters were passed along with the command
  33. /// \param[in] parameterList The list of parameters. parameterList[0] is the first parameter and so on.
  34. /// \param[in] transport The transport interface we can use to write to
  35. /// \param[in] systemAddress The player that sent this command.
  36. /// \param[in] originalString The string that was actually sent over the network, in case you want to do your own parsing
  37. bool OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, const SystemAddress &systemAddress, const char *originalString);
  38. /// You are responsible for overriding this function and returning a static string, which will identifier your parser.
  39. /// This should return a static string
  40. /// \return The name that you return.
  41. const char *GetName(void) const;
  42. /// A callback for when you are expected to send a brief description of your parser to \a systemAddress
  43. /// \param[in] transport The transport interface we can use to write to
  44. /// \param[in] systemAddress The player that requested help.
  45. void SendHelp(TransportInterface *transport, const SystemAddress &systemAddress);
  46. /// Records the instance of RakPeer to perform the desired commands on
  47. /// \param[in] rakPeer The RakPeer instance, or a derived class (e.g. RakPeer or RakPeer)
  48. void SetRakPeerInterface(RakNet::RakPeerInterface *rakPeer);
  49. protected:
  50. /// Which instance of RakPeer we are working on. Set from SetRakPeerInterface()
  51. RakPeerInterface *peer;
  52. };
  53. } // namespace RakNet
  54. #endif
  55. #endif // _RAKNET_SUPPORT_*
粤ICP备19079148号