Re: [twsocket] Design principles of WebSockets server for ICS
Hi Fredrik, Here is the ICS-based WebSockets server, which I've sent to Francois but did not get a response. All websockets-related stuff is implemented as a set of classes/units inside 'websockets' folder. Actually, this is a port of phpws project available at http://code.google.com/p/phpws/. There is no a specific component for websockets, they are handled internally from a custom TTcpSrvClient. The test project uses port number 12345 for websocket connections by default. Test client web-page is also included and uses the same port. Best wishes, Stan - Original Message - From: Fredrik Larsson To: 'ICS support mailing' Sent: Friday, March 16, 2012 4:08 PM Subject: Re: [twsocket] Design principles of WebSockets server for ICS Hi, I would be very interested in trying out and test this websocket-component. I don't think that there is a huge need for a Delphi-client of websocket yet (I might be wrong though) but the serverside is very interesting. With websocket you can communicate with your system without the webbrowser having to re-fetch data every second or so depending on your system. When there is data the server simply send it. First of all a simple chat-window on a website is a typical usage. I can also imagine surveillance system where you need to monitor data in realtime. Online games is probably another usage.. Regards, Fredrik. -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of François Piette Sent: den 4 mars 2012 16:25 To: 'ICS support mailing' Subject: Re: [twsocket] Design principles of WebSockets server for ICS By the way, I don't really understand the real world use case for such "WebSockets" in the context of a IC/Delphi/WebServer application. Unless you have to support and existing client application, it is IMO not very interesting. Maybe I'm wrong. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
Hi, I would be very interested in trying out and test this websocket-component. I don't think that there is a huge need for a Delphi-client of websocket yet (I might be wrong though) but the serverside is very interesting. With websocket you can communicate with your system without the webbrowser having to re-fetch data every second or so depending on your system. When there is data the server simply send it. First of all a simple chat-window on a website is a typical usage. I can also imagine surveillance system where you need to monitor data in realtime. Online games is probably another usage.. Regards, Fredrik. -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of François Piette Sent: den 4 mars 2012 16:25 To: 'ICS support mailing' Subject: Re: [twsocket] Design principles of WebSockets server for ICS By the way, I don't really understand the real world use case for such "WebSockets" in the context of a IC/Delphi/WebServer application. Unless you have to support and existing client application, it is IMO not very interesting. Maybe I'm wrong. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
Hi Francios, To go back to your initial design question, it is probably better to start with the THttpAppSrv component which is by far the most advanced one to build dynamic web application backend. As the THttpAppSrv is a decendant of THttpServer, it requires the same or even larger amont of rework of base components, IMHO. As I wrote before, if we suppose to leave base components as is, then in order to support websocket connection I need to override important methods of both these components, copy/paste all the http-related code from such methods and interlace it with websocket-related additions. I don't like this approach, because we lose http-code inheritence (if some fixes are made in the base components, they will not be available in the websockets server). The most important limitation of the appoach with THttpAppSrv is the same as with THttpServer: it implies two components to serve clients on different ports (one for web-pages and one for web-sockets). But I'd prefer websockets-server to handle connections on the same (presumably standard) port, as the hosting web-server does. IMHO, this is only possible if websockets-support are built-in into the components themselves. Also, I must say that a web-server (THttpServer) is probably the closest candidate to work with websockets, because app-server seems excessive for most common web tasks. Currently, I have an application, utilizing web-server, and I don't see a reason to transform it into an app-server. Did you receive my codes sent yesterday? As you may see, current approach is very simple in the sense that it uses standard web-server and a custom HttpConnection object with websockets functionality. If the issue with different ports can be treated as unimportant, I'd be happy with this approach. Best wishes, Stan -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
>>By the way, I don't really understand the real world use case for such >>"WebSockets" in the context of a IC/Delphi/WebServer application. >>Unless you have to support and existing client application, it is IMO >>not very interesting. Maybe I'm wrong. > The websockets supersede the old AJAX approach with requesting each > portion of data by separate http-request. WebSockets allow you to do the > same without overheads on HTTP-headers, which may be very large in > comparison with your data, if you're exchanging with small data elements. OK, I understand. You want to support existing client. Sounds good to me. To go back to your initial design question, it is probably better to start with the THttpAppSrv component which is by far the most advanced one to build dynamic web application backend. If you don't know that component yet, have a look at the [unfinished] tutorial : http://wiki.overbyte.be/wiki/index.php/TutWebAppServer -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
Hi Francois, As I understand, you are trying to - or you already have - implement RFC6455, server side (http://tools.ietf.org/rfc/rfc6455.txt). Is that correct ? You are right, but we code supports both hixie and hybie protocols. By the way, I don't really understand the real world use case for such "WebSockets" in the context of a IC/Delphi/WebServer application. Unless you have to support and existing client application, it is IMO not very interesting. Maybe I'm wrong. The websockets supersede the old AJAX approach with requesting each portion of data by separate http-request. WebSockets allow you to do the same without overheads on HTTP-headers, which may be very large in comparison with your data, if you're exchanging with small data elements. Best wishes, Stan -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
Hi Angus, Now that web browsers are implementing it (http://en.wikipedia.org/wiki/WebSocket#Browser_support), it would be nice to have support for it from ICS too. OK, so this is just server push under another name. You are wrong, because this is not just another name of the server push, but a different prototol. Also this is a full-duplex connection. To implement either the client or server using ICS, we need the opposing client and servers for demonstration, debugging and testing. As a rule, the client is a modern browser. For a server, we need HTML page code with the Javascript to access the websockets server from a browser. Of course, I have such a test page in the distribution kit. For a client, we need a URL of an existing public server using websockets, which will presumably be dynamically updating a web page. I did not have a goal to implement websockets client, though it can be done with support of other units which are already implemented for websockets support, such as handshaking, framing, and message building. If people reading this list wish to contribute either or both of these testing environments, adding websockets will be much faster. I'll send what I have. Angus Best wishes, Stan -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
> Now that web browsers are implementing it > (http://en.wikipedia.org/wiki/WebSocket#Browser_support), it would > be nice to have support for it from ICS too. OK, so this is just server push under another name. To implement either the client or server using ICS, we need the opposing client and servers for demonstration, debugging and testing. For a server, we need HTML page code with the Javascript to access the websockets server from a browser. For a client, we need a URL of an existing public server using websockets, which will presumably be dynamically updating a web page. If people reading this list wish to contribute either or both of these testing environments, adding websockets will be much faster. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
On 04-03-2012 15:24, François Piette wrote: I don't really understand the real world use case for such "WebSockets" in the context of a IC/Delphi/WebServer application Now that web browsers are implementing it (http://en.wikipedia.org/wiki/WebSocket#Browser_support), it would be nice to have support for it from ICS too. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
Hello Stan, As I understand, you are trying to - or you already have - implement RFC6455, server side (http://tools.ietf.org/rfc/rfc6455.txt). Is that correct ? There are several ways to implement that using ICS. I don't know the best one since I have not read RFC6455 in details. Candidates are TWSocket, TWSocketServer, THttpServer and THttpAppSrv. Gave the candidates in order of inheritance. At first glance, the highest level is the best because you will less reinvent existing code. By the way, I don't really understand the real world use case for such "WebSockets" in the context of a IC/Delphi/WebServer application. Unless you have to support and existing client application, it is IMO not very interesting. Maybe I'm wrong. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -Message d'origine- De : twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] De la part de Stan Envoyé : dimanche 4 mars 2012 16:09 À : ICS support mailing Objet : [twsocket] Design principles of WebSockets server for ICS Hi Everybody, I have a WebSockets server based on ICS. It is currently implemented as a tcp-server (TWSocketServer without any modifications) with custom descendant of TWSocketClient, which provides all necessary functionality for WebSockets handshaking and data exchange. We could use it in ICS projects right away, but I'm not sure if this is a proper approach. Lets consider an ordinary use-case for websockets: a client is a browser's built-in websocket, and the socket is instantiated by a web-page code. The web-page itself is normally served by a web-server located on the same host which is an endpoint of the websocket connection. So, standard http- port is used by the web-server, and a dedicated tcp-server (for websockets) is required to listen at a non-standard port, which may be not allowed by some firewalls. On the other hand, we can suppose that the web-server is an ICS-based web-server. So, it is feasible to combine web-server and websockets-server in a single component, serving websockets on standard http-port. I think, this is only possible if the current THttpServer component (actually, meaning with the THttpConnection component) is extended and reworked. That is deriving new components from the existing ones will require overriding of most important virtual methods and copy-pasting much of http-related code into the new methods, what is not good. The reason for this is the need to interlace little yet distinctive websocket code fragments with existing code. In other words, it would be necessary anyway to transform such methods as THttpConnection.ConnectionDataAvailable into a highly templatized methods splitted into several new virtual stages/branches each. Are there some other design principles for implementing this? I'd be glad to hear your opinions, considerations on which variant is the best, and suggestions on implementation. If the general consesus is that current design is sufficient for the moment, I'll send the sources to Francois. Best wishes, Stan -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Design principles of WebSockets server for ICS
> I think, this is only possible if the current THttpServer component > (actually, meaning with the THttpConnection component) is extended > and reworked. That is deriving new components from the existing ones > will require overriding of most important virtual methods and > copy-pasting > much of http-related code into the new methods, what is not good. Surely your WebSocket (whatever that is, never heard of it) application should be based on THttpAppSrv which is specifically designed for custom web applications, but still supports static web pages? Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be