[udp] add template SocketIn class for easier socket usage (#10392)

This commit adds a new template `Udp::SocketIn<Owner, RxHandlerPtr>`,
which defines a UDP socket for use within a specified `Owner` class.
It includes a `HandleUdpReceive()` member method callback for
processing received messages. This model, similar to `TimerMilliIn`,
eliminates the need for each socket user to define boilerplate code
for providing a static member function that simply casts and calls
the member method. This is now handled by the template `SocketIn`
class. The `Udp::Socket::Open()` method is also modified to no longer
require the callback and context parameters.
This commit is contained in:
Abtin Keshavarzian
2024-06-17 18:31:26 -07:00
committed by GitHub
parent 4749aa2ae0
commit 54afce92ab
25 changed files with 129 additions and 129 deletions
+2 -2
View File
@@ -1068,7 +1068,7 @@ void TestSrpClientDelayedResponse(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Prepare a socket to act as SRP server.
Ip6::Udp::Socket udpSocket(*sInstance);
Ip6::Udp::Socket udpSocket(*sInstance, HandleServerUdpReceive, nullptr);
Ip6::SockAddr serverSockAddr;
uint16_t firstMsgId;
Message *response;
@@ -1076,7 +1076,7 @@ void TestSrpClientDelayedResponse(void)
sServerRxCount = 0;
SuccessOrQuit(udpSocket.Open(HandleServerUdpReceive, nullptr));
SuccessOrQuit(udpSocket.Open());
SuccessOrQuit(udpSocket.Bind(kServerPort, Ip6::kNetifThread));
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -