https://github.com/BanTheRewind/Cinder-Protocol
With Cinder-Asio reaching a decent level of maturity, we're
ready to move over to the protocol layer. If you've been
following
this
thread, you'll know we've been working towards creating a
comprehensive, high performance, and flexible networking library that
is easy to use.
A big decision made along the way was to avoid the pitfall of most
of these libraries and decouple the transport (how data is sent),
protocol (what data is sent), and encryption layers. This should give
us a solid toolkit to do anything from talk to hardware at high speed
on a private network to implementing WebSockets from the ground up
(and not deal with the mess that is WebSocketsPP).
WHAT IT IS
Cinder-Protocol follows a similar philosophy and style as
Cinder-Asio in that there is a lot of inheritance. This makes it easy
to implement protocols that follow the top line + header fields + body
format (HTTP, FTP, SMTP, WebSockets, etc) while allowing the
flexibility to work with non-standardized fields, or even invent your
own protocol.
Right now it, looks like this:
The base class is really generic, just supporting the concept of
a key-value pair header and a separate body, alongside some
utilities for converting between strings, byte buffers, and a << for just
streaming the entire object. HttpInterface adds
HTTP versioning to to base class, while the HttpRequestand HttpResponse classes
finish out structuring the data (ie, status code, reason, etc).
The block includes sample projects for a web client and HTTP client
and server. The master branch has an in-progress FTP sample. It works,
I just need to write out more communication and find a set up a test server.
WHAT IT ISN'T
Cinder-Protocol is not meant to support standards. That is, you
can create and parse a valid HTTP request and/or response, but it is
going to remain agnostic about what the content of your header fields
and body are. The body is just a byte buffer. The header fields are
just pairs of strings. If a web site has a "non-standard"
field, Cinder-Protocol will support it without any sort of warning.
It's up to you to filter that stuff out.
This library focuses on web protocols. OSC is considered a
"protocol", but doesn't fit the definition of
"protocol" the same way HTTP, FTP, or SMTP do.
Side note, OSC is more akin to JSON or
XML in our eyes. Mike Latzoni has been working on an OscTree not
unlike XmlTree or JsonTree. It's close, and it's totally awesome...
HELP
We'd love PRs on this one. If you have lots of experience
implementing SMTP, FTP, RTMP, etc, we'd really like to see
versions of those akin to the HTTP classes. FTP has already been started.
Anywho, give it a shot and leave some
feedback. If there are any actual issues, please bring them up in
the repo, not here.
http://www.BanTheRewind.com