Overview
Comment: | OFDatagramSocket: Rework blocks-based API |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
61b5fb53bd33ca1d3f42519ab7c14968 |
User & Date: | js on 2024-10-27 13:47:39 |
Other Links: | manifest | tags |
Context
2024-10-27
| ||
14:07 | OFSCTPSocket: Rework blocks-based API check-in: b06f8e3e89 user: js tags: trunk | |
13:47 | OFDatagramSocket: Rework blocks-based API check-in: 61b5fb53bd user: js tags: trunk | |
11:38 | OFPlugin: Allow path to be nil check-in: 5aba968988 user: js tags: trunk | |
Changes
Modified src/OFDatagramSocket.h from [5622561ae5] to [89443d90ed].
︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | + + - + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + | @class OFData; @class OFDatagramSocket; #ifdef OF_HAVE_BLOCKS /** * @brief A block which is called when a packet has been received. * * @deprecated Use @ref OFDatagramSocketPacketReceivedHandler instead. * * @param length The length of the packet * @param sender The address of the sender of the packet * @param exception An exception which occurred while receiving or `nil` on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^OFDatagramSocketAsyncReceiveBlock)(size_t length, |
︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | + + - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + | runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * @deprecated Use @ref asyncReceiveIntoBuffer:length:handler: instead. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer * @param block The block to call when the datagram has been received. If the * block returns true, it will be called again with the same * buffer and maximum length when more datagrams have been * received. If you want the next method in the queue to handle * the datagram received next, you need to return false from the * method. */ - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length |
︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | + + - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + | receiver: (const OFSocketAddress *)receiver runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously sends the specified datagram to the specified address. * * @deprecated Use @ref asyncSendData:receiver:handler: instead. * * @param data The data to send as a datagram * @param receiver A pointer to an @ref OFSocketAddress to which the datagram * should be sent. The receiver is copied. * @param block The block to call when the packet has been sent. It should * return the data for the next send with the same callback or nil * if it should not repeat. */ - (void)asyncSendData: (OFData *)data receiver: (const OFSocketAddress *)receiver |
︙ |
Modified src/OFDatagramSocket.m from [7c8f8ff231] to [ad1fa374f4].
︙ | |||
255 256 257 258 259 260 261 | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + - + | runLoopMode: (OFRunLoopMode)runLoopMode { [OFRunLoop of_addAsyncReceiveForDatagramSocket: self buffer: buffer length: length mode: runLoopMode # ifdef OF_HAVE_BLOCKS |
︙ | |||
344 345 346 347 348 349 350 | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + - + | runLoopMode: (OFRunLoopMode)runLoopMode { [OFRunLoop of_addAsyncSendForDatagramSocket: self data: data receiver: receiver mode: runLoopMode # ifdef OF_HAVE_BLOCKS |
︙ |
Modified src/OFRunLoop+Private.h from [525119de79] to [8d9cb60c01].
︙ | |||
105 106 107 108 109 110 111 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | - + - + | block: (nullable id)block delegate: (nullable id)delegate; + (void)of_addAsyncReceiveForDatagramSocket: (OFDatagramSocket *)socket buffer: (void *)buffer length: (size_t)length mode: (OFRunLoopMode)mode # ifdef OF_HAVE_BLOCKS |
︙ |
Modified src/OFRunLoop.m from [11ea957026] to [b4516d8680].
︙ | |||
171 172 173 174 175 176 177 | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | - + - + | } @end @interface OFRunLoopDatagramReceiveQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS |
︙ | |||
893 894 895 896 897 898 899 | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | - - + + - + | sender: &address]; } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS |
︙ | |||
936 937 938 939 940 941 942 | 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 | - - + + | length: _data.count * _data.itemSize receiver: &_receiver]; } @catch (id e) { exception = e; } # ifdef OF_HAVE_BLOCKS |
︙ | |||
974 975 976 977 978 979 980 | 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 | - + | } # endif } - (void)dealloc { # ifdef OF_HAVE_BLOCKS |
︙ | |||
1450 1451 1452 1453 1454 1455 1456 | 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 | - + - + - + - + | } + (void)of_addAsyncReceiveForDatagramSocket: (OFDatagramSocket *)sock buffer: (void *)buffer length: (size_t)length mode: (OFRunLoopMode)mode # ifdef OF_HAVE_BLOCKS |
︙ |