--
Sourceforge
https://sourceforge.net/projects/civetweb/
---
You received this message because you are subscribed to the Google Groups "civetweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to civetweb+u...@googlegroups.com.
To post to this group, send email to cive...@googlegroups.com.
Visit this group at http://groups.google.com/group/civetweb.
To view this discussion on the web visit https://groups.google.com/d/msgid/civetweb/1d497b0b-6327-411d-ba1a-a26f51aba7d4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
So Model 3a - "one Lua state per websock connection" has several drawbacks.
The other extreme alternative 3b would be "one Lua state for all websocket connections", and 3c is a hybrid solution.
So Model 3a - "one Lua state per websock connection" has several drawbacks.
The other extreme alternative 3b would be "one Lua state for all websocket connections", and 3c is a hybrid solution.
Design consideration 1:
How to translate the script path?
-----------------------------------------------
Websocket actually has its own root hierarchy. A websocket address is typically opened in a way like (JavaScript code):
websocket_connection = new WebSocket("ws://" + window.location.host + "/MyPath/ToSomeWhere");
So you replace http:// (or https://) by ws://, add the IP and have your resource path.
Alternatives:
1a) You could use the same document root path on the server side for http:// and ws://
In this case Websocket Lua scripts must have a specific file extention,
and http and https requests should not display these files (you dont want to show the server side Lua source to the clients in the browser).
1b) You could use a different document root path on the server side, which means a new config of an additional path.
1c) You could use just one Lua script for all websocket requests. This means a new config of an additional file.
The actual websock resource path is passed on to the Lua script file. Then you can still decide in Lua to split to load and invoce an additional script.
This is both, the solution that is most simple to implement and that offers the highest flexibility.
So I would go for "1c".
Any objections?
Would they need a specific extension?
One minor gripe I have with mongoose (and CW, I assume; haven't tried it yet) is that you can't have a .lua file handle a request directly, you have to run it though a .lp file. Couldn't .lua files be served up through Lua instead of as plain text, ...
... and then we could use the same -url_rewrite_patterns to point websocket requests at the appropriate file (inside or outside of the document root)?
If they're inside the document root, -hide_files_patterns should cover that, shouldn't it?
It seems like this would offer a lot of flexibility without needing any new config, but I may be missing something. I guess you'd want to provide the URI scheme to Lua, so the script can check that it's actually a websocket request, but I feel like it should be there anyway. Right now there is no way to distinguish between http and https on regular Lua pages as far as I know.
How would you map the resource path to the Lua files, though? People probably don't want their resource paths ending with ".lua".
That should work, but it would mean you'd always need a sort of "router script" if you're using multiple resource paths, and it seems like that routing could be handled by -url_rewrite_patterns and organization of scripts within the filesystem instead. Something feels off to me about having a single entrypoint for all websocket requests, but I can't put my finger on it.
I'm sure you'll figure out the best way to handle it, just throwing this out there as food for thought.
[...]
Ed Swift:One minor gripe I have with mongoose (and CW, I assume; haven't tried it yet) is that you can't have a .lua file handle a request directly, you have to run it though a .lp file. Couldn't .lua files be served up through Lua instead of as plain text, ...
Well, it would be simple to add support for using lua files directly instead through the .lp files. It is also possible to use Lua through CGI by using the Lua standalone interpreter as CGI interpreter. An example how lp and CGI are related is currently here
https://github.com/sunsetbrew/civetweb/tree/master/test/ajax
An additional possibility to use Lua directly, similar to the CGI but as in-server module could easily be added. In fact I thought about that, since it is certainly simpler to program in Lua.
Its not a big deal to implement in the webserver and not a real complication to maintain, yet it would be a third way to invoke Lua - still I do see some advantages .. where advantages would it have for you?
... this was all about "normal" web pages here, not about websockets.
Ed Swift:... and then we could use the same -url_rewrite_patterns to point websocket requests at the appropriate file (inside or outside of the document root)?
I haven't used url_rewrite_patterns myself, but I think it will still not serve the purpose here:
It would have to distinguish between http(s)://server.xy/file.lws and ws://server.xy/file.lws - the first one must not find the websocket script "file.lws" at all, the second one must do the websocket operation.
Ed Swift:If they're inside the document root, -hide_files_patterns should cover that, shouldn't it?
Well, one should not have to configure it. But in principle you are right, one would use the same mechanism as for hiding password files (you also do not need to add the ".htpasswd" manually to the hide_file_patterns config).
Ed Swift:It seems like this would offer a lot of flexibility without needing any new config, but I may be missing something. I guess you'd want to provide the URI scheme to Lua, so the script can check that it's actually a websocket request, but I feel like it should be there anyway. Right now there is no way to distinguish between http and https on regular Lua pages as far as I know.
In Lua there is a string in the variable mg.request_info.http_headers.Referer, e.g. "http://localhost/". I guess this would be "https://".. for a https connection.
But no, I dont want to let Lua decide if it is a websocket request or not. The server already knows that. A websocket connection is also not really a page like the "*.lp" pages are. Its a script that exports a set of functions that are called on websocket operations. The <? some_lua_code ?> syntax of *.lp pages is unsuitable for websockets - the plain Lua script (your *.lua = my *.lws discussed above) would work.
Ed Swift:How would you map the resource path to the Lua files, though? People probably don't want their resource paths ending with ".lua".
In the case of using a separate resource path I don't need any file endings. One can either use files that do not have any endings, or append the *.lws or *.lua in the server.
Ed Swift:That should work, but it would mean you'd always need a sort of "router script" if you're using multiple resource paths, and it seems like that routing could be handled by -url_rewrite_patterns and organization of scripts within the filesystem instead. Something feels off to me about having a single entrypoint for all websocket requests, but I can't put my finger on it.
One bad thing clearly is that two completely independent projects, both using websockets, cannot be served by the same webserver without having to write a specific script.
This is actually one of the problem I saw in 3b.
Ed Swift:I'm sure you'll figure out the best way to handle it, just throwing this out there as food for thought.
Thanks for contributing to this discussion. I'm just trying to make it as simple as possible for the Lua users and yet flexible enough.
I'm definitely leaning toward 3b now.
A good example I ran into recently is a REST server I'm working on that only sends JSON, never HTML. It works under CGI, but is designed to work under other environments as well. Mongoose support is there and working (with some hacks, MG doesn't expose all the info I need in request_info, but that's going OT).
For the Mongoose support to work, I need to add .lp files that essentially just contain <? require 'somefile.lua' ?>. Since things like CGILua also support Lua pages (same extension but with a different syntax), I imagine this is confusing to someone looking at the project.
We probably shouldn't have to, but do we already have to configure it hide .lua files, since they'll get served up as plain text. Serving .lua files through Lua would fix that, though.
Well, the usual mantra is "never trust Referer," because it's sent from the client, so it can be spoofed or mangled by proxies or erased off by privacy things. I think it would be good to have the scheme in that request_info table, but that's probably OT for this thread if the Lua script won't be deciding whether it was a websocket request anyway.
Files with no endings would work, but I think .lua would feel the nicest. There's really no reason to name it .lws, is there? It's just a regular Lua script, after all, with access to some special table of websocket stuff. With regular .lua extensions we don't have to jump through hoops to get our text editors to realize we're editing Lua scripts.
A good example I ran into recently is a REST server I'm working on that only sends JSON, never HTML. It works under CGI, but is designed to work under other environments as well. Mongoose support is there and working (with some hacks, MG doesn't expose all the info I need in request_info, but that's going OT).
The websocket application I've got in mind serves text that is interpreted as operations with SVG objects, so that's a quite similar problem. What did you miss in request_info?
For the Mongoose support to work, I need to add .lp files that essentially just contain <? require 'somefile.lua' ?>. Since things like CGILua also support Lua pages (same extension but with a different syntax), I imagine this is confusing to someone looking at the project.
I know ;-)
But changing this will break compatibility here.
We probably shouldn't have to, but do we already have to configure it hide .lua files, since they'll get served up as plain text. Serving .lua files through Lua would fix that, though.
One reason why I did not want to use the extension *.lua: If you use 'require something' in Lua, it opens the file 'something.lua', so I can distinguish between pages that are accessible from the webserver, and libraries that can be required but do not form pages by themselves and are not served directly.
Well if you compare to CGILua again, they do use the .lua extension (for those who do not know what we mean - see here: http://keplerproject.github.io/cgilua/manual.html), and hiding *.lua libraries can certainly be done differently than by putting them into the document root and hiding them.
Well, the usual mantra is "never trust Referer," because it's sent from the client, so it can be spoofed or mangled by proxies or erased off by privacy things. I think it would be good to have the scheme in that request_info table, but that's probably OT for this thread if the Lua script won't be deciding whether it was a websocket request anyway.
I agree, one should at least have the server port accessible in Lua.
Files with no endings would work, but I think .lua would feel the nicest. There's really no reason to name it .lws, is there? It's just a regular Lua script, after all, with access to some special table of websocket stuff. With regular .lua extensions we don't have to jump through hoops to get our text editors to realize we're editing Lua scripts.
Well, again I would distinguish between serve-able scripts (lws) and pure libraries (lua), but this can certainly be done differently - see above.
- remote_ip = 2130706433
For CGI, the protocol (http vs. https) is not available in SERVER_PROTOCOL but in a variable HTTPS. This the case for the current CGI implementation here and it's common (see e.g., http://stackoverflow.com/questions/16825243/why-is-phps-server-protocol-showing-http-1-1-even-when-using-https).
The remote ip would be much nicer as a string. Maybe add remote_ipv4 / remote_ipv6 and leave remote_ip alone in case anyone was using it?
Yes, probably best to stick with CGI names. RFC 3875 also has a nice list on page 2, but doesn't include non-standard (but common) ones like PATH.As long as we're going a bit off-topic here, how would you guys feel about letting Lua and CGI handle PUT/DELETE requests?I need to be able to handle PUT and DELETE requests, and PATCH would be nice too. Looking at handle_request, I see that there is some checking for "is_put_or_delete_request" and calls to "send_authorization_request" before control gets passed off to the Lua or CGI script.Could we add an option to allow CGI and Lua to handle requests with any HTTP method, or just move those bits of code up a few lines and hope nobody was using built-in PUT/DELETE handling and CGI/Lua scripts together in some weird way that would cause this to break their app?
Am Samstag, 9. November 2013 05:18:55 UTC+1 schrieb Ed Swift:Yes, probably best to stick with CGI names. RFC 3875 also has a nice list on page 2, but doesn't include non-standard (but common) ones like PATH.As long as we're going a bit off-topic here, how would you guys feel about letting Lua and CGI handle PUT/DELETE requests?I need to be able to handle PUT and DELETE requests, and PATCH would be nice too. Looking at handle_request, I see that there is some checking for "is_put_or_delete_request" and calls to "send_authorization_request" before control gets passed off to the Lua or CGI script.Could we add an option to allow CGI and Lua to handle requests with any HTTP method, or just move those bits of code up a few lines and hope nobody was using built-in PUT/DELETE handling and CGI/Lua scripts together in some weird way that would cause this to break their app?
off-topic ?
For me, in the beginning Websockets + Lua was just a combination of two existing features. If there are issues in one of the base features, I think they need to be discussed and solved if possible. It's not a good idea to build a new feature on top of something that should have been looked at in more detail before.
Technically both features work well, but I agree, the Lua programming interface chosen for the Lua generated pages is somewhat ad hoc.
For me, in addition to the advantages of Lua already mentioned ("powerful, fast, extendible, small footprint", http://www.lua.org/about.html#what), there is one more advantage: It is a designed language, not a grown one.
What we do here is providing a programming interface from the C part for our users of the Lua part. The Lua standard libraries already do have a well designed and well documented interface. Also we should provide a well designed interface here (and if the server is embedded in another application, allow the host application to add a well designed interface - this is already possible). This interface should be the same for 'normal' Lua pages, and for websockets, maybe apart from minimal differences that are directly caused by the somewhat different mode of operation. It should be at least possible to do the same in Lua as in CGI.
PUT/DELETE requests
While a GET and a POST request are directed to existing resources, a PUT request is not. A PUT request is meant to add a new resource that does not exist.
So "PUT /somewhere/something.lua HTTP/1.1" means create a file /somewhere/something.lua with the content of the request - it does not mean call the Lua script /somewhere/something.lua and give it the data of the request - that would be a POST request. In analogy "DELETE /somewhere/something.lua HTTP/1.1" does not mean call the file /somewhere/something.lua but just remove this file from the server (without calling it first). In other words: A "PUT"/"DELETE" request is not supposed to be handled by the resource, but it adds/removes the resource itself.
One could thing about adding one particular "PUT" and "DELETE" Lua script. This script would be called for all "PUT" and/or "DELETE" requests. It will have access to the resource name and decide what to do. One restriction is, that it will only be possible to have one such PUT/DELETE handling script per server, so two independent contents on the same server cannot have two independent PUT/DELETE handling scripts. The alternative is to handle file creation and deletion at the server by using a POST request. This is already possible and there can be as many independent scripts as you like.
Where do you see the advantage of PUT/DELETE vs. POST?
I have to think about PATCH - on the one hand it is similar to PUT/DELETE since it is supposed to change the resource instead of calling it, on the other hand, in contrast to PUT/DELETE a server will always require a script for doing a PATCH request.
Now suppose all requests to "/somewhere/..." are redirected to "/controller.lua"
I don't exactly agree with this. I think the mistake here is equating "resource" with "file.""DELETE /somewhere/something.lua" should certainly mean "delete that Lua script," but what about something like:DELETE /somewhere/user/12 HTTP/1.1This probably means "delete the user with an id of 12," and the resource probably represents something like a row in a database table, not a file.
Now suppose all requests to "/somewhere/..." are rewritten to "/controller.lua" and it's up to controller.lua to figure out what to do based on the http method and resource path. So, controller.lua sees that it's a DELETE request for user/12, and it deletes user 12 from the database (after checking appropriate permissions and so on).
The is the way a normal RESTful server would work. You wouldn't want to use something like...GET /somewhere/user/12?action=delete HTTP/1.1...because it doesn't really jive with the way REST is supposed to work. To create a true RESTful server, we need to be able to handle PUT and DELETE the same way we can handle GET or POST.
If you just want to decide everything in Lua, you could just call mg_exec_lua_script in the begin_request callback - mg_exec_lua_script is a global function that is already providing support *.lua (not *.lp) files.
Do you compile the server yourself, or are you using a prebuilt binary?
I guess the question is whether we care if Civetweb is useful for tools like this, or if we'd rather let the built-in handling keep priority over scripts (with no way to override it).Here's what I wonder, though. Maybe people are using the built in PUT/DELETE handling to store documents and static stuff, but how many people are using them to upload/remove executable CGI scripts or Lua pages? If people are doing this, *should* they be? To me that just sounds like a problem waiting to happen; surely there is a better way to deploy. How much harm would really be done by just letting the scripts handle those requests? Is it possible that the order things are handled in was not carefully planned and the PUT/DELETE check just happened to end up before the CGI / Lua page checks? Maybe the intent was never to prevent scripts from handling those requests, but nobody ran into the problem before now?
I thought about the problem, and I think the best behavior of the server would be the following:
1) if there is a request, check if the uri is a file (like somewhere/something.html or somewhere/something.cgi), or another resource handled by a script (like somewhere/something.cgi/someone or users.lsp/user123), or does not exist
2) it a put/delete request is directed to a file, ask for the put/delete permission (i.e., current behavior) - the same for a PUT request for a new file
3) if ANY request is addressing a resource handled by the script, forward it to the script. A *.cgi file is a script, a plain lua file (*.lsp) is a script, but I would not see a *.lp file as a script (it's a text file that may contain script elements within special tags).
This would be compatible with the previous behavior. PUT requests to resources handled by a script did not work up to now anyway, so it's just an extension.
What do you think?
I'm not sure .lp shouldn't count as a script. While it might technically not be a script, I think the important distinction to make might be "static resources" vs. "dynamic resources." Unless you think people might have some good reason to want to delete Lua pages from their server in this way, or there is some technical reason it can't be done, I think it might be better just to pass the request on to Lua.
Consider a case where someone runs the standalone server with "-url_rewrite_patterns /api/**=/controller.lp"
Suppose the client sends `DELETE /api/user/12`. The requested resource was `/api/user/12`, which is not a file that exists; it's a "dynamic resource." Civetweb looks at the rewrite patterns and sees that "controller.lp" wants the request. Doesn't it make the most sense to pass the request on to controller.lp? You can't delete /api/user/12 since it's not a file, and deleting controller.lp would be silly. There's really no other sensible option, is there?
I realize the Lua pages aren't ideal for handling something like a DELETE, since it may not even want to send a body, but I'm also worried about Civetweb and Mongoose needlessly diverging. For example, I don't want to end up needing both a "foo.lp" and a "foo.lsp" file containing nothing but `require "foo"` if I want to support both Mongoose and Civetweb. If we treat .lp files as scripts, it might make it easier for Moongoose to follow suit (because they could do it without having to support .lsp)
By the way, Mongoose actually used ".lsp" for Lua pages originally, until someone on the mailing list pointed out that .lsp is usually associated with Lisp. It might be a good idea to come up with a different name for those. I'd still be in favor of just using .lua, really. If it's a security concern, maybe it could be configurable and turned off by default, e.g. add something like "lua_file_extension" to config_options and have it default to NULL, and people who want to use regular Lua scripts instead of pages can set it to ".lua" or whatever else they like.
There are actually three different resources (plus not existing resources as case 4):
Otherwise you can use a rewrite pattern to replace it. I successfully tested url_rewrite_patterns /api/=r:\page2.lsp/ in Windows, so you can even remove the script completely from the document root.
That might be the explanation why there was already an almost working implementation for plain Lua scripts, that I just connected to a file extension (apparently the same again).
The most obvious name certainly is *.lsp (Lua Server Page), in analogy to *.jsp (Java Server Page), or *.asp, *.csp, *.psp, and one could rename lisp files to *.lisp as well.
Currently there is a config for "cgi_pattern" (default *.cgi, *.pl, *.php) and "ssi_pattern" (default *.shtm, *.shtml) so one could make one for "lsp_pattern" (I think *.lsp would be a good default). There is no option configure *.lp right now.
So for static and mixed, we keep the current behavior, and for dynamic, we pass the request to the script. That sounds good to me as long as we support plain Lua scripts and don't care about diverging from Mongoose.
I think .lp files should still be able to handle POSTs, though. Removing that functionality would break simple pages with forms that post to themselves.
I mean they used the .lsp for the Lua pages -- .lsp became .lp.
...
Actually this is the problem I see with the .lsp name. It is the most obvious name for a server page which is probably why Sergey used it instead of .lp at first
But we're not using it for a server page, we're using it for plain Lua. JSP, ASP, and PSP are a mix of static and dynamic content, just like our .lp files (I haven't heard of CSP). Naming plain Lua scripts ".lsp" does imply that they are like these other "mixed" formats, when really they aren't.
This sounds good. If I can't talk you into using .lua instead of .lsp, I at least want to be able to use it myself. ;)
A simpler approach to this might be including an option to turn off the default PUT/DELETE handling.
There are actually three different resources (plus not existing resources as case 4):
1) pure static content like *.html, *.css, *.png, ... in this case resource=file
The http methods would work like this:GET: deliver the page
POST: not supported
PUT: replace the resource file
DELETE: delete the resource file
2) static data with some elements that are determined on request like *.shtml (server side includes), and *.lp in the present form + *.lsp
The http methods would work basically identical to the first case:GET: deliver the page, fill in the missing elements
POST: not supported
PUT: replace the resource file
DELETE: delete the resource file
3) pure dynamic data like *.cgi and *.lua, ... in this case resource != file
The http methods would work differently:GET: forward request to the script4) a valid url could also address a non-existing resource not managed by a script
POST: forward request to the script
PUT: forward request to the script
DELETE: forward request to the scriptGET: error 404
POST: error 404
PUT: put it there as a file
DELETE: error 404
After studying and thinking for a while, the following suggestion:
- add a config parameter "lua_server_page_pattern", the default is *.lp and *.lsp (a difference between lp and lsp might indeed be somewhat difficult to understand, in particular since it apparently has changed in the past)
- add a config parameter "lua_script_pattern", the default is *.lua (*.lp and *.lsp are used above, and others used *.lua for this purpose as well)
- all options do only exist if you build with USE_LUA
- POST to *.lp should be deprecated - I do not know if anyone used it, since it does not even have the CGI equivalent field CONTENT_LENGTH yet. The previous categorization would still be valid (I just adapted the file extensions):
All these considerations and the previously mentioned additions are meant for Lua scripts triggered due to standard http or https requests, so we are not yet at the "websocket" part.
Still I think it was necessary to solve this before going on with the "Websocket for Lua" implementation, which was and still is the original intention of this thread.
If there are no objections, I would add all the patches mentioned above together with Websockets for Lua - they should be beneficial there as well. The changes should be compatible.
In the following I would focus again on WebSockets.
I used POST before, not in production, but just experimenting. You don't really need Content-Length because you can just keep calling mg.read until it returns nil (it just returns 1024 bytes or less at a time). I don't remember if Content-Length appeared in the table with the rest of the headers, but I don't see why it wouldn't. Are you sure it isn't there? Content-Type was definitely there (maybe worth noting since neither of those headers appear with the rest of the headers under Apache/CGI, since they have their own variables, I guess).
I'll take full blame for any sidetracking which may or may not have occurred. ;)There are still some other Lua problems (Civetweb forked off in the middle of some refactoring that broke stuff that is now fixed again in MG), but we should probably discuss them separately; they shouldn't slow down WebSockets. I know there are some people on this list who would probably prefer not to hear about Lua at all, so maybe we can consolidate other concerns into one thread.
Fixes for Lua Server Pages, as described within this thread. Added an example (test/page2.lp).
Added support for plain Lua Scripts, as described within this thread. An example script has been added (test/page2.lua).
These two examples also document the difference between *.lp (Lua Server Pages) and *.lua (Plain Lua Scripts).
A completely new, and more illustrative websocket example for C.
IMO the previous C programming example in examples/websocket/ did not show the essence of websocket communication, so I dropped it and made a completely new one. The build "ex_websocket" now uses the new example: Multiple clients can connect to the websocket by opening websock.htm. This page shows 4 buttons (A, B, C, D) and whenever one client pushes one button, all clients can see it. One can also type a letter within the server console window which is then transferred to all attached clients as well. Furthermore, the server periodically sends the server time to all clients. They display it within the title bar of the window. So this example is primarily on "push" communication from the server to the clients (instead of polling by the clients with periodic GET requests), and on client to client cross communication - so I think this kind of test application is showing the essentials of of a communication situation that may actually profit from websockets.
Update of SQLite3 to Version 3.8.1.
Add "date" header field to replies, according to the requirements of RFC 2616 (the HTTP standard), Section 14.18
Finally: An implementation of "Websocket for Lua". Again I added an example (test/websocket.xhtml and test/websocket.lua).
Note that the Lua programming interface may change, if the threading model
changes.
A change in the threading model is not actually required for "WebSockets for Lua", but if we choose to do a new threading model which may allow us an even better "Websocket for Lua" binding, I will adapt the Lua binding accordingly (if required or beneficial).
Everything should be compatible (unless someone exploited a bug).
Both LUA and WEBSOCKET remain optional features to civetweb. You have to enable both: USE_WEBSOCKET and USE_LUA to use Websockets for Lua.
Everything was tested on Windows + stress tested.
Still, if I accidentally broke something, tell me and I will have a look at it.
--To view this discussion on the web visit https://groups.google.com/d/msgid/civetweb/339ec1fc-fc73-4d36-91b1-b9140d602f47%40googlegroups.com.
Sourceforge
https://sourceforge.net/projects/civetweb/
---
You received this message because you are subscribed to the Google Groups "civetweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to civetweb+u...@googlegroups.com.
To post to this group, send email to cive...@googlegroups.com.
Visit this group at http://groups.google.com/group/civetweb.
We do have a pre-built package for mac. It is built using Makefile.osx
What we do not have yet is the <?=variable?> syntax for Lua Server Pages.
PHP has this as well (http://en.wikipedia.org/wiki/PHP_syntax_and_semantics#Variables_and_comments).
I think we (I) should add that.
WebSockets are a very useful feature in civetweb. You can use it to establish a connection to the server and let a the browser continuously exchange data with the server. The server can send data to the browser, the client does not need to poll repeatedly.
I've written a WebSocket server in PHP for my own use (test app at http://tonywilk.no-ip.org/angularjs/websocket.html , PHP source linked at the bottom)
which uses Sec-WebSocket-Protocol to provide different services in one websocket server. The above-linked example demonstrates some really simple protocols for 'echo', 'chat' and 'command'.
Simply: the client sends "Sec-WebSocket-Protocol: chat" and the server checks if "chat" is something it supports, if so it completes the handshake. Once a connection is running you can simply direct frames to a function to handle that protocol.
If your early 'direct websockets to a lua script idea' still holds - I think it would be a good idea to implement protocol so you can switch traffic based on the protocol in use rather than implementing some custom in-data method.
I tested your chat server, and this seems to do pretty much what I intended as a first test case for Websockets for Lua.I have to study your PHP script in more detail. Your websocket-server loop is directly programmed in PHP?
src="http://tonywilk.no-ip.org/angularjs/websocket.php"You are using host and protocol for opening a new websocket.
The websocket.php is just php (I'm running PHP version 5.3.15)
you can run it as CLI on a server or from a browser (see top of php source) - just pick an appropriate port number
You are using host and protocol for opening a new websocket.
Yes; note that the server is only allowed to send Sec-WebSocket-Protocol in the handshake if a client requests it.
In my case I make it mandatory.