cordova-plugin-websocket-server icon indicating copy to clipboard operation
cordova-plugin-websocket-server copied to clipboard

Minimal HTTP functionality

Open lobo-tuerto opened this issue 8 years ago • 6 comments

Hello,

I was wondering if it would be possible (and how difficult) to add minimal HTTP functionality to this server.

The use case would be: to be able to get HTML files from it.

This in turn could allow your Cordova app to serve the initial files to establish a connection, say from your PC to your phone (similar to what the AirDroid app does).

lobo-tuerto avatar Oct 02 '16 01:10 lobo-tuerto

Hi @lobo-tuerto

The idea behind this plugin was to have a pure WebSocket server. But a minimal HTTP functionality wouldn't hurt I guess. Allowing just HTTP GET to fetch resources (html, scripts, images...) and doing a Connection Upgrade to WebSocket.

I'm seeing two ways to do this:

  • replace implementations (TooTallNateServer with nanohttpd and PocketSocket with CocoaHTTPServer for instance). Maybe this could be a new plugin alongside this one but that'd be even more work.
  • or just add the minimal required code.

Serving files from a Phone to a PC is something that interest me as well. Even though I don't have much time right now I'll try to have a look at this. I'll keep you updated.

For the time being you can use cordova-plugin-httpd

becvert avatar Oct 03 '16 14:10 becvert

Well, thanks for the reply!

Yeah I was having a look around during the weekend and came to the conclusion that NanoHTTPD is a pretty good option (for Android) as it already support HTTP + WS.

And I had a look at cordova-plugin-httpd and wrote a quick demo with it (but still missing WS). So I was planning on using both plugins (cordova-plugin-httpd and yours) in the same app, but I think it would be better to just have one that does HTTP & WS.

If you are planning on writing a new plugin I might be able to help, at least in API & feature design.

lobo-tuerto avatar Oct 03 '16 14:10 lobo-tuerto

FYI, I will try nanohttp and cocoahttpserver this week or sometime very soon hopefully. I'm a bit afraid of cocoahttpserver as it seems to be no longer maintained. But maybe it does not matter much.

becvert avatar Oct 31 '16 08:10 becvert

I don't like much nanohttpd's websocket server implementation. But I just found out WSHttpServer. Looks promising.

becvert avatar Nov 04 '16 21:11 becvert

I've got some bad news. I'm not happy with my tests. I don't find an easy way to add the minimal http functionality. It's too much work for now. And as I don't have much time to spend on this, I'm giving up, Hopefully someone else will step into that issue with a solution.

becvert avatar Nov 07 '16 20:11 becvert

All right, thanks for trying though!

I don't have much time on my hands these days too, but will see if I can come up with something later.

Cheers!

lobo-tuerto avatar Nov 07 '16 22:11 lobo-tuerto