File tree Expand file tree Collapse file tree 5 files changed +43
-5
lines changed
include/Polymorph/Network Expand file tree Collapse file tree 5 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ namespace polymorph::network
2323 struct Packet
2424 {
2525 PacketHeader header;
26+
27+ /* *
28+ * @property The packet payload, contains the data to send
29+ * @tparam T The type of the payload
30+ */
2631 T payload;
2732 }
2833#ifdef _WIN32
Original file line number Diff line number Diff line change @@ -22,9 +22,24 @@ namespace polymorph::network
2222#endif
2323 struct PacketHeader
2424 {
25+ /* *
26+ * @property The packet operation code, used to identify the packet action
27+ */
2528 OpId opId;
29+
30+ /* *
31+ * @property The packet identifier, used to uniquely identify a packet (in a short time)
32+ */
2633 PacketId pId;
34+
35+ /* *
36+ * @property The session identifier, used to identify the session
37+ */
2738 SessionId sId ;
39+
40+ /* *
41+ * @property The packet payload size, used to know the size of the payload
42+ */
2843 PayloadSize pSize;
2944 }
3045#ifdef _WIN32
Original file line number Diff line number Diff line change @@ -170,9 +170,6 @@ namespace polymorph::network::tcp
170170 */
171171 void _doReceive ();
172172
173- // TODO: remove ?
174- bool _broadcastReceivedPacket (const PacketHeader &header, const std::vector<std::byte> &bytes);
175-
176173
177174// ////////////////////--------------------------/////////////////////////
178175
Original file line number Diff line number Diff line change @@ -20,14 +20,32 @@ namespace polymorph::network::tcp
2020 public:
2121 virtual ~IClientConnection () = default ;
2222
23+ /* *
24+ * @brief Start accepting connection
25+ */
2326 virtual void start () = 0;
2427
28+ /* *
29+ * @brief Send a packet to the client
30+ * @tparam T The type of the payload
31+ * @param payload The payload to send
32+ * @param callback The callback to call when the packet is sent
33+ */
2534 virtual void send (std::vector<std::byte> data, std::function<void (const PacketHeader &, const std::vector<std::byte> &)> callback) = 0;
2635
36+ /* *
37+ * @brief Check if the client is connected
38+ */
2739 virtual bool isConnected () = 0;
2840
41+ /* *
42+ * @brief Get the current client session id
43+ */
2944 virtual SessionId getSessionId () = 0;
3045
46+ /* *
47+ * @brief Get the current last packet id
48+ */
3149 virtual PacketId getPacketId () = 0;
3250 };
3351}
Original file line number Diff line number Diff line change @@ -46,10 +46,13 @@ namespace polymorph::network::udp
4646 ServerPacketManager _packetManager;
4747
4848 /* *
49- * @brief The session store used to manage the sessions
49+ * @property The session store used to manage the sessions
5050 */
5151 SessionStore &_sessionStore;
5252
53+ /* *
54+ * @property The safeties map used to determine if a packet require ack or not
55+ */
5356 std::map<OpId, bool > _safeties;
5457
5558
@@ -70,7 +73,7 @@ namespace polymorph::network::udp
7073 * @param from The recipient of the initial packet
7174 * @param acknowledgedId The acknowledged packet id
7275 */
73- void ackReceived (const asio::ip::udp::endpoint& from, PacketId acknowledgedId);
76+ void ackReceived (const asio::ip::udp::endpoint& from, PacketId acknowledgedId) override ;
7477
7578 /* *
7679 * @brief Method called when a packet is sent, it confirms the sent and enable the auto re-send feature for safe packets
You can’t perform that action at this time.
0 commit comments