mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 19:27:46 +00:00
[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:
@@ -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));
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
Reference in New Issue
Block a user