If we send the capability answer back on a message, then the server has to keep state of the capability it has to send on the next message. Which in turn implicates that before a server can send a message it always has to check if there is a capability it has to add to the message. By sending it directly back, we do not have to check on every future message if there is a capability we have to add. Thus, I propose the following protocol to handle capabilities where at most 3 notifications are exchanged after establishing a connection.
if connection is not yet cached, establish new connection and add capabilities to first message.
on receive of a msg with capability and hash understood: send a message back containing a notification(type: capabilityAnswer, data: )
on receive of a msg with capability and hash not understood: send a message back containing a notification(type:capability hash not understood, data:)
on receive of a notification capabilityAnswer and other capability understood: notice capability
on receive of a notification capabilityAnswer and other capability not understood: send a msg
containing notification(type: capability hash not understood, data:)
on receive of a notification capability not understood and other capability understood: send a msg containing notification(type: capabilityAnswer, data:)
on receive of a notification capability not understood and other capability not understood: send a msg containing notification(type: capability hash not understood, data:)
on receive of a notification capability not understood and with no capability data: send a msg containing notification(type: capabilityAnswer, data:)
This approach also allows servers which only push information to negotiate capabilities and upgrade their connection.
this is fine, but is implementation-specific and actually doesn't need to be defined in the draft. I've made it clear that dedicated messages are okay.
If we send the capability answer back on a message, then the server has to keep state of the capability it has to send on the next message. Which in turn implicates that before a server can send a message it always has to check if there is a capability it has to add to the message. By sending it directly back, we do not have to check on every future message if there is a capability we have to add. Thus, I propose the following protocol to handle capabilities where at most 3 notifications are exchanged after establishing a connection.
if connection is not yet cached, establish new connection and add capabilities to first message. on receive of a msg with capability and hash understood: send a message back containing a notification(type: capabilityAnswer, data:)
on receive of a msg with capability and hash not understood: send a message back containing a notification(type:capability hash not understood, data:)
on receive of a notification capabilityAnswer and other capability understood: notice capability
on receive of a notification capabilityAnswer and other capability not understood: send a msg
containing notification(type: capability hash not understood, data:)
on receive of a notification capability not understood and other capability understood: send a msg containing notification(type: capabilityAnswer, data:
) on receive of a notification capability not understood and other capability not understood: send a msg containing notification(type: capability hash not understood, data:
) on receive of a notification capability not understood and with no capability data: send a msg containing notification(type: capabilityAnswer, data:
)
This approach also allows servers which only push information to negotiate capabilities and upgrade their connection.