Differences From Artifact [6654ade8b5]:
- File src/OFUDPSocket.h — part of check-in [da2dd2dde5] at 2018-12-08 18:55:26 on branch trunk — OFUDPSocket: Use a delegate for async operations (user: js, size: 13264) [annotate] [blame] [check-ins using]
To Artifact [ab6554e3b4]:
- File
src/OFUDPSocket.h
— part of check-in
[064dbe5127]
at
2018-12-11 22:57:46
on branch trunk
— Include an exception in delegate methods
Otherwise, there would be two methods for every operation: One for
success and one for failure. It also makes it easy to forget about
handling failure, so it's better to always pass an optional exception. (user: js, size: 12830) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 | /*! * @brief This method is called when a packet has been received. * * @param socket The UDP socket which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param sender The address of the sender of the packet * @return A bool whether the same block should be used for the next receive */ - (bool)socket: (OF_KINDOF(OFUDPSocket *))socket didReceiveIntoBuffer: (void *)buffer length: (size_t)length | > > | > > | | < < < < < < < < < < < < < < < < < < < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | /*! * @brief This method is called when a packet has been received. * * @param socket The UDP socket which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param sender The address of the sender of the packet * @param exception An exception that occurred while receiving, or nil on * success * @return A bool whether the same block should be used for the next receive */ - (bool)socket: (OF_KINDOF(OFUDPSocket *))socket didReceiveIntoBuffer: (void *)buffer length: (size_t)length sender: (of_socket_address_t)sender exception: (nullable id)exception; /*! * @brief This which is called when a packet has been sent. * * @param socket The UDP socket which sent a packet * @param buffer A pointer to the buffer which was sent. This can be changed to * point to a different buffer to be used on the next send. * @param length The length of the buffer that has been sent * @param receiver The receiver for the UDP packet. This may be set to a new * receiver to which the next packet is sent. * @param exception An exception that occurred while sending, or nil on success * @return The length to repeat the send with or 0 if it should not repeat. * The buffer and receiver may be changed, so that every time a new * buffer, length and receiver can be specified while the callback * stays the same. */ - (size_t)socket: (OF_KINDOF(OFUDPSocket *))socket didSendBuffer: (const void *_Nonnull *_Nonnull)buffer length: (size_t)length receiver: (of_socket_address_t *_Nonnull)receiver exception: (nullable id)exception; @end /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * * @brief A class which provides methods to create and use UDP sockets. * |
︙ | ︙ |