sociomantic-tsunami / swarm

Asynchronous client/node framework library
Boost Software License 1.0
14 stars 26 forks source link

`RequestOnConn.receive` should pass received data as `Const(void)[] data` #303

Closed nemanja-boric-sociomantic closed 5 years ago

nemanja-boric-sociomantic commented 6 years ago

Currently, RequestOnConnBase.receive passes the received data to the receive callback delegate as in void[] data (https://github.com/sociomantic-tsunami/swarm/blob/f337984496e0f08d08f4be5997b4272d9c0e0dab/src/swarm/neo/connection/RequestOnConnBase.d#L1029). This prevents the user changing this slice, so the user needs to do Const!(void)[] payload_slice = payload in order to be able to pass the data trough the MessageParser.get* methods, for example.

There's no need that the entire slice stay constant, it's has the scope of the delegate and it can safely be non-const. However, the data it points to should stay const, so it would be better if the delegate had the following signature:

void receive (Const(void)[] data)
gavin-norman-sociomantic commented 5 years ago

Fixed in #397.