You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

netmessagemaker.h 1020B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2016 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #ifndef STARWELS_NETMESSAGEMAKER_H
  6. #define STARWELS_NETMESSAGEMAKER_H
  7. #include "net.h"
  8. #include "serialize.h"
  9. class CNetMsgMaker
  10. {
  11. public:
  12. CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
  13. template <typename... Args>
  14. CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
  15. {
  16. CSerializedNetMsg msg;
  17. msg.command = std::move(sCommand);
  18. CVectorWriter{ SER_NETWORK, nFlags | nVersion, msg.data, 0, std::forward<Args>(args)... };
  19. return msg;
  20. }
  21. template <typename... Args>
  22. CSerializedNetMsg Make(std::string sCommand, Args&&... args) const
  23. {
  24. return Make(0, std::move(sCommand), std::forward<Args>(args)...);
  25. }
  26. private:
  27. const int nVersion;
  28. };
  29. #endif // STARWELS_NETMESSAGEMAKER_H