christianparpart / x0

Xzero HTTP Application Server
MIT License
109 stars 16 forks source link

add Web Sockets plugin #14

Open christianparpart opened 14 years ago

christianparpart commented 14 years ago

add a plugin supporting the server side for the web sockets protocol.

Ideally, but optionally, I could implement a client-side javascript library that either communicates to the browser's native WebSocket API, or implements a javascript based own one.

akamiru commented 11 years ago

is someone working on that ?

christianparpart commented 11 years ago

Hey akamiru,

I am sorry but no, webdav ist currently just a whishlist, as i am working on Themen Lord balancer (director) plugin and stability right now. Although, i could need it myself :-)

Are you just interested in it or do you cobsider Holding such a plugin yourself?

Cheers, Christian. Am 11.12.2012 23:30 schrieb "akamiru" notifications@github.com:

is someone working on that ?

— Reply to this email directly or view it on GitHub.

christianparpart commented 11 years ago

Sorry for some wrong words. My mobile phone thinks it knows better :) Am 11.12.2012 23:30 schrieb "akamiru" notifications@github.com:

is someone working on that ?

— Reply to this email directly or view it on GitHubhttps://github.com/xzero/x0/issues/14#issuecomment-11267612.

akamiru commented 11 years ago

http://www.damnyouautocorrect.com/ ;) no problem.

Well I haven't got that much time. But with a little help, I think I could at least try to write a plugin. Maybe you can give me more info e.g. how the Flow interface should look like.

Is there a way in xzero to force the server to send a chunk or aren't the ->Write<>()-calls buffered ?

Alternatives could be implemented as Ajax/SSE or Long Polling Ajax. Not that heavy I think.

Cheers, Christoph

christianparpart commented 11 years ago

Hey,

well, I do not get the point of Ajax/SSE with regards to WebDAV here, however ... :)

WebDAV itself is just an extension to HTTP/1.1 in terms of request methods AFAIK (corrent me if I am wrong), and thus, GET is already implemented. I now also saw that my stub webdav plugin also already handles the PUT method, but the most important PROPFIND and everything else related to XML processing hasn't been done yet, and I'd maybe do it now a little bit different now than I did it in the first place. so the current webdav plugin would need some polishing.

However, I am currently also trying hard on getting the website done cool, including documentation for usage and development material (coding guidelines, etc). but documenting is always a hard thing and will take time.

Flow: this is the configuration language, yes, and I think you don't think a webdav plugin needs more than already done:

registerHandler<WebDAVPlugin, &WebDAVPlugin::handleRequest>("webdav");

this registers a request handler that can be triggered from within the configuration file via webdav() w/o any parameters, so the simplest form of a handler.

Response Composition: yes, buffered writing is of course supported, the basic form of writing a chunk to the client is via request->write<TYPE>(data) where TYPE can be for example BufferSource to write a fully managed buffer, BufferRefSource as kind of a unmanaged memory region (e.g. a sub-region of another managed memory buffer) or FileSource to sent a partial or complete file to the client [1]. The latter is automatically optimizing to take advantage of zero networking (via sendfile()-syscall) as well as when writing from a PipeSource it is using the splice()-syscall to for zero copy networking. You may want to check out the include/x0/io/ [2] to get a list of possible source types you can pass to the client.

The arguments of the HttpRequest::write<TYPE>(...) call are passed to the TYPE's constructor [3]

And while I think you already found the hello_example-plugin [3] I'd like to encourage you to have a look at the director plugin and how I did things there, as this is the plugin that gets by far the most attention from me currently. Have a look at the ApiRequest.cpp which encapsulates an administrative RESTful request to this plugin and makes use of lots of custom request methods [4].

Hope this helps so far :) Christian.

[1] https://github.com/xzero/x0/blob/master/lib/http/HttpCore.cpp#L1040 [2] https://github.com/xzero/x0/tree/master/include/x0/io [3] https://github.com/xzero/x0/blob/master/plugins/hello_example.cpp [4] https://github.com/xzero/x0/blob/master/plugins/director/ApiRequest.cpp

On Wed, Dec 12, 2012 at 11:09 AM, akamiru notifications@github.com wrote:

http://www.damnyouautocorrect.com/ ;) no problem.

Well I haven't got that much time. But with a little help, I think I could at least try to write a plugin. Maybe you can give me more info e.g. how the Flow interface should look like.

Is there a way in xzero to force the server to send a chunk or aren't the ->Write<>()-calls buffered ?

Alternatives could be implemented as Ajax/SSE or Long Polling Ajax. Not that heavy I think.

Cheers, Christoph

— Reply to this email directly or view it on GitHubhttps://github.com/xzero/x0/issues/14#issuecomment-11283276.

christianparpart commented 11 years ago

fuck, I was thinking of the WebDAV plugin while you were talking about WebSockets. ugh, that's a little more complicated as you upgrade the protocol. I did not start on working on this one yet :(

akamiru commented 11 years ago

Hey Christian,

no problem ^^ Maybe I will take a look at WebDav and start to work on this plugin first ;)

christianparpart commented 11 years ago

Don't mind asking. We can also meet in IRC org Skype at day or in the evening.

I also hope the documentation will become better soon. :-) Am 12.12.2012 13:09 schrieb "akamiru" notifications@github.com:

Hey Christian,

no problem ^^ Maybe I will take a look at WebDav and start to work on this plugin first ;)

— Reply to this email directly or view it on GitHubhttps://github.com/xzero/x0/issues/14#issuecomment-11286524.