ConsoleServer.h 3.1 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. /// \file ConsoleServer.h
  11. /// \brief Contains ConsoleServer , used to plugin to your game to accept remote console-based connections
  12. ///
  13. #include "NativeFeatureIncludes.h"
  14. #if _RAKNET_SUPPORT_ConsoleServer==1
  15. #ifndef __CONSOLE_SERVER_H
  16. #define __CONSOLE_SERVER_H
  17. #include "RakMemoryOverride.h"
  18. #include "DS_List.h"
  19. #include "RakNetTypes.h"
  20. #include "Export.h"
  21. namespace RakNet
  22. {
  23. /// Forward declarations
  24. class TransportInterface;
  25. class CommandParserInterface;
  26. /// \brief The main entry point for the server portion of your remote console application support.
  27. /// \details ConsoleServer takes one TransportInterface and one or more CommandParserInterface (s)
  28. /// The TransportInterface will be used to send data between the server and the client. The connecting client must support the
  29. /// protocol used by your derivation of TransportInterface . TelnetTransport and RakNetTransport are two such derivations .
  30. /// When a command is sent by a remote console, it will be processed by your implementations of CommandParserInterface
  31. class RAK_DLL_EXPORT ConsoleServer
  32. {
  33. public:
  34. // GetInstance() and DestroyInstance(instance*)
  35. STATIC_FACTORY_DECLARATIONS(ConsoleServer)
  36. ConsoleServer();
  37. ~ConsoleServer();
  38. /// \brief Call this with a derivation of TransportInterface so that the console server can send and receive commands
  39. /// \param[in] transportInterface Your interface to use.
  40. /// \param[in] port The port to host on. Telnet uses port 23 by default. RakNet can use whatever you want.
  41. void SetTransportProvider(TransportInterface *transportInterface, unsigned short port);
  42. /// \brief Add an implementation of CommandParserInterface to the list of command parsers.
  43. /// \param[in] commandParserInterface The command parser referred to
  44. void AddCommandParser(CommandParserInterface *commandParserInterface);
  45. /// \brief Remove an implementation of CommandParserInterface previously added with AddCommandParser().
  46. /// \param[in] commandParserInterface The command parser referred to
  47. void RemoveCommandParser(CommandParserInterface *commandParserInterface);
  48. /// \brief Call update to read packet sent from your TransportInterface.
  49. /// You should do this fairly frequently.
  50. void Update(void);
  51. /// \brief Sets a prompt to show when waiting for user input.
  52. /// \details Pass an empty string to clear the prompt
  53. /// Defaults to no prompt
  54. /// \param[in] _prompt Null-terminated string of the prompt to use. If you want a newline, be sure to use /r/n
  55. void SetPrompt(const char *_prompt);
  56. protected:
  57. void ListParsers(SystemAddress systemAddress);
  58. void ShowPrompt(SystemAddress systemAddress);
  59. TransportInterface *transport;
  60. DataStructures::List<CommandParserInterface *> commandParserList;
  61. char* password[256];
  62. char *prompt;
  63. };
  64. } // namespace RakNet
  65. #endif
  66. #endif // _RAKNET_SUPPORT_*
粤ICP备19079148号