If you write a chat room, there are many technologies that can be used, but in addition to technology, what functions should be considered in advance, which features more than users, more practical, can ask some netizens who often chat, they generally give You a more satisfactory answer. Aspects, such as Perl, CGI (EXE), ASP, ISA are basic server-side technology, ActiveX, Java, VBScript, and JScript are client technology.
In terms of efficiency, the efficiency of the server-side technology is in turn, and the client technology declines sequentially, but VBScript and JScript efficient are similar.
From the function, ISA has the strongest function, CGI (exe) secondly, Perl has not been used; the client is the strongest, JScript, Java, and VBScript have not been used: P.
From ease of use, ASP is the strongest, followed by Perl, is the most improper ISAPI; the client is the best, Java next to VBScript and JScript.
Based on my understanding, the chat room can be divided into two categories: refresh-based and Server PUSH. The chat room for previous (including now) is based on refresh, this benefit is - achieving easy. Disadvantages: First, the server side must save enough users to say, which seriously affects server-side performance, and, due to frequent transfer of duplicate information, the bandwidth of the network is greatly wasting; second, the information sent by the user cannot be displayed immediately Other users, of course, improve the refresh interval can improve this situation, but this will cause more network load. Server Push Technology is a recent emerging technology. It only needs a user to perform (or few times a few times) request, then constantly send the user to the latest information, effectively avoiding the above drawbacks; its disadvantage is difficult Big. This is mainly discussed to discuss the chat room of Server Push technology.
Earlier, the NS browser supports a PUSH form of MIME encoding (X - ???), where the following data segments can automatically cover the previous data segments, which is said to be easier to implement Server Push, but Since it is supported by NS, but IE does not support, it is not interested. If you are interested, you can check the relevant information.
There is a way to implement server push simultaneously in IE and NS, which is to use "PENDING". As we all know, in view of certain larger webpages, while the bandwidth is small, a part of the web page will be displayed to the user, using this, you can achieve high performance chat room. The server side is to do, when there is information to be sent to the user, send the information as usual, but when there is no new information, it is not turned off, but it is suspended, and does not send any information to the user. Until the new information arrives. When the new message arrives, the send immediately recovers, just like never interrupt. In this way, from the client, there is no difference from the page with a slower page. From the perspective of the chat room, users only need to submit a request until they are valid, avoid repeating refresh; only the new information is necessary to transfer new information on the network, effectively utilize the bandwidth of the network; all new information is sent immediately, And you don't have to wait for the user to refresh, enhance the immersibility.
To give an example: 263 (Capital Online) chat room uses this technology, let's analyze: its client uses a frame, there are some control, coordinated scripts reside in the main frame. The PENDING page is the page that displays all users (a frame). When a new message is in this framework, it has an immediate execution script, which calls the function in the main frame with the information content as a parameter. The function in the main framework returns the information content back to the speech page, and is also responsible for updating the list of users on the right. The PENDING page is submitted to a special port of the server (non-80), which has a service in listening, its task is - implementing Pending on the HTTP protocol, what is the specific service? If you don't know, it will not be difficult to achieve it.
However, 263 This approach I don't think it is the best. First of all, its server side is implemented: using a special port is not wise, it should be more convenient to integrate this service into the WWW service (after all, you have to interact with users, integrate into WWW service, you can get WWW Many support provided by the service). There is too little work in the client, and now the client has strong performance. Is it afraid that the user is angry? Saved server-side resources can be better (for example, more timely). When the number of users increases, the server-side resource is limited and will be consumed quickly, but client resources are growing. Therefore, it is possible to put the work to the client as long as it is possible. In most cases, this can also save network bandwidth.
So, for my implementation (first declare, I don't have any content of the plagiarism 263, when my second chat room is completed, I found that 263 similar technology - I almost don't chat, huh, huh) . I have two chat rooms (of course, the second better), but all uses similar techniques. The first chat room is completely ISAPI. At that time, it would just prove that Server Push technology can be realized, the efficiency is low, and it is very troublesome; the second, it is now coming, ISAPI, ASP and COM combination It has been better maintenance (benefit from ASP), and the core part optimizes Win2000 to achieve high performance. (Attent, the first achievement "possible" is much greater than the second, however, the first maintenanceability is relatively second, the second is the other, and the second is still a second good J) I directly said that the second achieved ~~~ (love guy who loves the void).
Part of the ISAPI is responsible for the page of the page; COM part is responsible for calculating intensive or time-sensitive operations and management, and is responsible for the interaction of the ISAPI part and the ASP; the ASP part does not have to be said, responsible for most (except the Pending page) and client interaction And some lightweight management transactions. In the client, you do not use the frameset (Frameset), and use the IFRAME in a single page. Use two iframes to make a Pending page, and it is submitted. That is, when an excessive information is placed, the next one is automatically submitted, clearing the original, avoiding excessive waste information in the client. Using a short interval timer, constantly check if there is a new message coming in by Push, if there is, unload the message, distribute to the corresponding IFRAME, reside in the corresponding IFRAME is responsible for managing the message in some form. (Note: IE does not provide a way to perceive the new message to reach the pending page. I have wanted to know through the onDateavailable, the result failed, I had to use the timer, the shortcomings of this, the result of arrival, there will be a delay, The longest time for this delay is the timer trigger interval. Maybe I should connect to the 263 to Push, but in turn, the error may cause the IE error, and the detection mechanism can be used to capture errors with the TRY block, can be recovered; if Each Push message script is wrapped in a TRY block, even if the error is captured, it is not easy to handle - the handler is also in the pending page, if it also passes wrong? Since the front script is wrong, Try itself will Will not be wrong? ........... I still need to consider it).
What is said above is just the main structure, and the details are much more detailed, almost the source code. The above content is more likely to be analyzed from the performance of the realization, I will not be difficult to analyze everyone, anyway, it is possible to be analyzed (note: not necessarily), it is better to publish. The server-side implementation details, I am not going to publish (will you also analyze it? Maybe it will be announced, see how we decide), because it may involve future security; but the main structure is there, the ideas are there. I think this is the most important part. As long as you have a little ability, you can design a server, which may be much better than me. As for the client implementation, of course, a slight use point means can master each detail, in order to facilitate everyone, save you time, when our chat room client is basically fixed, I will make it into a package, for everyone free download J .