PacketChangerPlugin.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #pragma once
  11. #include "RakNetTypes.h"
  12. #include "PluginInterface2.h"
  13. #include "PacketPriority.h"
  14. #include "MessageIdentifiers.h"
  15. #include "InternalPacket.h"
  16. using namespace RakNet;
  17. class PacketChangerPlugin: public PluginInterface2
  18. {
  19. public:
  20. PacketChangerPlugin(void);
  21. ~PacketChangerPlugin(void);
  22. /// \param[in] peer the instance of RakPeer that is calling Receive
  23. void OnAttach(void) {}
  24. /// Called when the interface is detached
  25. /// \param[in] peer the instance of RakPeer that is calling Receive
  26. void OnDetach(void) {}
  27. /// Update is called every time a packet is checked for .
  28. void Update(void) {}
  29. /// OnReceive is called for every packet.
  30. /// \param[in] packet the packet that is being returned to the user
  31. /// \return True to allow the game and other plugins to get this message, false to absorb it
  32. PluginReceiveResult OnReceive(Packet *packet) {(void) packet; return RR_CONTINUE_PROCESSING;}
  33. /// Called when RakPeer is initialized
  34. void OnStartup(void) {}
  35. /// Called when RakPeer is shutdown
  36. void OnShutdown(void) {}
  37. /// Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
  38. /// \param[in] systemAddress The system whose connection was closed
  39. /// \param[in] rakNetGuid The guid of the specified system
  40. /// \param[in] lostConnectionReason How the connection was closed: manually, connection lost, or notification of disconnection
  41. void OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ){(void) systemAddress; (void) rakNetGUID; (void) lostConnectionReason;}
  42. /// Called when we got a new connection
  43. /// \param[in] systemAddress Address of the new connection
  44. /// \param[in] rakNetGuid The guid of the specified system
  45. /// \param[in] isIncoming If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent
  46. void OnNewConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming) {(void) systemAddress; (void) rakNetGUID; (void) isIncoming;}
  47. /// Called when a connection attempt fails
  48. /// \param[in] systemAddress Address of the connection
  49. /// \param[in] failedConnectionReason Why the connection failed
  50. void OnFailedConnectionAttempt(Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason) {(void) failedConnectionAttemptReason;}
  51. /// Called on a send to the socket, per datagram, that does not go through the reliability layer
  52. /// \param[in] data The data being sent
  53. /// \param[in] bitsUsed How many bits long \a data is
  54. /// \param[in] remoteSystemAddress Which system this message is being sent to
  55. void OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
  56. /// Called on a receive from the socket, per datagram, that does not go through the reliability layer
  57. /// \param[in] data The data being sent
  58. /// \param[in] bitsUsed How many bits long \a data is
  59. /// \param[in] remoteSystemAddress Which system this message is being sent to
  60. void OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
  61. /// Called on a send or receive of a message within the reliability layer
  62. /// \param[in] internalPacket The user message, along with all send data.
  63. /// \param[in] frameNumber The number of frames sent or received so far for this player depending on \a isSend . Indicates the frame of this user message.
  64. /// \param[in] remoteSystemAddress The player we sent or got this packet from
  65. /// \param[in] time The current time as returned by GetTimeMS()
  66. /// \param[in] isSend Is this callback representing a send event or receive event?
  67. void OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, TimeMS time, int isSend);// {(void) internalPacket; (void) frameNumber; (void) remoteSystemAddress; (void) time; (void) isSend;}
  68. /// Called when we get an ack for a message we reliabily sent
  69. /// \param[in] messageNumber The numerical identifier for which message this is
  70. /// \param[in] remoteSystemAddress The player we sent or got this packet from
  71. /// \param[in] time The current time as returned by GetTimeMS()
  72. void OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, TimeMS time) {(void) messageNumber; (void) remoteSystemAddress; (void) time;}
  73. /// System called RakPeerInterface::PushBackPacket
  74. /// \param[in] data The data being sent
  75. /// \param[in] bitsUsed How many bits long \a data is
  76. /// \param[in] remoteSystemAddress The player we sent or got this packet from
  77. void OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
  78. };
粤ICP备19079148号