Sender: LuckyBoy (Hai Xiang Sky ~ Breakbu) - Online list and user statement. Online lists can be used directly to use large object arrays, which is based on a chat room capacity. And the user's statement is directly sent to the pipeline. The definition of the online list class is as follows: Class Chaater {private static double id; // This ID is used as the difference number, and the private double socketID; // is associated with the Socket corresponding to the chat main frame. Private string nickname; // User Nickname Private String Passwd; // User Nickname Private Int PriviGe; // Private String [] filter; // A user's filter list private double login_time; // Remove login time, used to clear some Timeout join private string color; // User chat color ... // is limited to space, omitting the relevant method. } Note: Most of the above user data is in the Login phase, and the user fills in the same manner. Only SocketID wants to wait until the chat master (a normal chat interface includes chat main frame, speaking frame, three parts of the line list frame) will be obtained later. If it is more than a certain period of time, SocketID still has not been filled, indicating that the browser acquires the main framework, and the user data needs to be deleted. If you want to implement private chat like SOHU, you should also increase the properties of the user IP address. The user's definition is as follows: class content {private double timestamp; // Timestamp Private Double fromChaterid; // Speaker ID Private Double TOCHERID; // Chat Object ID Private Boolen ISSecurity; // Whether private chat Sign Private String Thecontent; // Chat content, handled in the builder, which already includes HTML text, etc. ... // Limited to the space, omitted the relevant method. } The core ThreadedChathandle class is the main process of analyzing user requests. The value of the request sent by the client, mainly there is login (verify identity, display chat room main frame), JoinChat, such as a welcome, etc., display chat content display frame, and keep the connection, send chat information.), Showtalk (Displayed Frame), Names (Show online list frame), Leave (user click button to leave the chat room), etc..
If we use the GET method to pass the data instead of submitting a form via the POST method, the user data input is transmitted in the URL. Below is a few URL instances, combined with the client process, better understand the function of the Threadedchathandle class: this Is a username password all the chat user login system of 'aaa', saying "Hello", then quit a series of requests: / login? Name = aaa & passwd = aaa / joinChat? CHATERID = 555 / showtalk? CHATERID = 555 / Names? CHATERID = 555 / speak? CHERID = 555 / Leave? CHERID = 555 ... The above is the server program process. In fact, the delivery of our parameters cannot only pass a CHATERID, and there is a corresponding authentication. Names delivers a CHATERID to update the time you visit in the online list class, avoid connection timeout. Below we look at the specific login process from the client. The chat interface consists of three frames, where JoinChat frame is a chat content display section; showTalk frame is the user input section, including chat content input, action, filtering, and management functions are in this frame; Names is an online list display section, this Part of the timing is refreshed. Let's take a look at the process of entering the chat room from the perspective of your browser.
◆ First browser request page http: // Host: 8080 / login? Name = name & passwd = PWD At this time a threadedchathandle appears (including a socket connection), and sends a line of data: get / login? Name = name & passwd = PWD HTTP / 1.1 ◆ Server generates a session ID, after verifying password, send back: http / 1.1 200 ok