romshark / webwire-go

A transport independent asynchronous duplex messaging library for Go
MIT License
216 stars 9 forks source link

Request message requires a payload #22

Closed KernelPryanic closed 6 years ago

KernelPryanic commented 6 years ago

Request message requires a payload even though a payload shouldn't be obligatory. In some cases a request name is sufficient. For example if we just want to notify the server about an event like client.Request("event_a_happend", wwr.Payload{}) then we won't need a payload, but currently we have to provide a payload otherwise an error is returned indicating that the request message couldn't be parsed.

WEBWIRE_ERR: 2018/05/15 18:26:36 serverHttp.go:72: Failed parsing message: Invalid request message, too short
romshark commented 6 years ago

I think we shouldn't require a request message to include a payload indeed though in this case we must require it to at least have a name:

Name Payload Error
-
- -
- -
- - ProtocolError
romshark commented 6 years ago

As of commit b498cca the webwire server will now accept request messages that either provide a name only or a payload only, or both. It'll reject request messages without both the name and the payload returning a MsgInternalError reply (can be improved by returning a new type of special reply message "MsgReplyProtoError" that's not yet implemented in the protocol version 1.4)

The server now also won't break the connection in case of a protocol/parser error.