Breaking Datagram API change.#25
Conversation
|
|
||
| DatagramCallback* = proc(transp: DatagramTransport, | ||
| remote: TransportAddress): Future[void] {.gcsafe.} | ||
| message: seq[byte], |
There was a problem hiding this comment.
openArray[byte] tends to give more flexibility for the implementation.. a common option later on is to allow the original caller to set up a byte buffer of their choice..
There was a problem hiding this comment.
this is also the kind of place where Result is appropriate - giving either an error or a buffer but never both - makes for cleaner code everywhere
There was a problem hiding this comment.
@arnetheduck we can't use openarray[T] because it can't be captured inside of iterator, so it can't work in async procedures.
| remote: TransportAddress): Future[void] {.gcsafe.} | ||
| message: seq[byte], | ||
| remote: TransportAddress, | ||
| error: OSErrorCode): Future[void] {.gcsafe.} |
There was a problem hiding this comment.
Seems like error which can happen here is either not realistic or unrelated to remote-specific message receiving. Thus I would consider removing the error from this function signature. For remote-unrelated events I would introduce another callback like onNetworkChanged.
There was a problem hiding this comment.
Sorry, but chronos is cross-platform framework, and if Linux has small number of errors, BSD/MacOS and Windows has much more, so i wish to leave error code here.
message - UDP message bytes.
If len(message) == 0 you need to check
OSErrorCodeto obtain error code.