Summary of the invention
In view of this, the invention provides a kind of method that forms structure tree, utilize this method can be simply and easily to form the message structure tree that structure is abundant, meaning is complicated, extensibility is strong, avoid proprietary protocol mutual between client and the server simultaneously, save the development amount in client.
In order to realize goal of the invention, the invention provides a kind of method that forms structure tree, this method comprises:
A, will comprise the real-time live client of instant messaging and carry out the extend markup language xml configuration file compression of the structure tree information of program presentation and be saved on the server;
B, the real-time live client of instant messaging are downloaded the xml configuration file from server;
Instant communication client decompress in this locality described configuration file and execution in step C:
C, the real-time live client of instant messaging read the attribute of the structure tree information that comprises in the xml configuration file, form structure tree layer by layer according to attribute; Described step C comprises:
C1, the real-time live client of instant messaging read the current clauses and subclauses under the outermost layer label, judge whether the attribute of current clauses and subclauses belongs to global configuration information, if next clauses and subclauses as current clauses and subclauses, are returned and carried out this step; Otherwise, the root node of generating structure tree, the root node name is called the name attribute of current clauses and subclauses;
C2, the real-time live client of instant messaging read the configuration attribute of the bar current sub-clauses and subclauses now that generate root node, on structure tree, generate first order node according to configuration attribute, and judge whether current sub-bar exists the configuration attribute of sub-clauses and subclauses now, if, execution in step C3; Otherwise as current sub-clauses and subclauses, circulation is carried out this step and all till the first order node according to configuration attribute generating structure tree, is withdrawed from this flow process until the sub-clauses and subclauses of now all of bar that generate root node with the bar next son clauses and subclauses now that generate root node;
C3, the real-time live client of instant messaging read the configuration attribute of current sub-bar clauses and subclauses now, on the correspondence position of structure tree, generate the next stage node according to configuration attribute, and judge whether the sub-bar that generates the next stage node also exists the configuration attribute of sub-clauses and subclauses now, if, the sub-bar clauses and subclauses now that generate the next stage node as current sub-clauses and subclauses, are returned and carried out this step; Otherwise the next stage node that this step is all set according to the complete generating structure of configuration information until the sub-clauses and subclauses of now all of current sub-bar is carried out in circulation, and the individual sub-clauses and subclauses of now next of bar that generates root node as current sub-clauses and subclauses, are returned execution in step C2;
Wherein, be modified in the programme information that the real-time live client of instant messaging represents by the structure tree information of revising in the described xml file.
Described step B comprises: client utilizes HTML (Hypertext Markup Language) http regularly to download the xml configuration file from server.
Described steps A comprises: described configuration file compression is saved on the server.
Described step C further comprises: client decompresses in this locality.
The above server is an instant communication server.
From above scheme as can be seen, a kind of method that forms tree provided by the invention has following beneficial effect:
1, downloads support easily and saved the development amount, the xml configuration file can be downloaded by the most frequently used http agreement, do not need to develop independent server processes, need not carry out the exploitation and the clients corresponding exploitation of server end, also avoided carrying out mutual trouble, and after the compression, the size of configuration file is about about 3~5K by proprietary protocol, downloading flow is little, and speed is fast;
2, do not need the client of instant messaging to carry out logic and come performance structure tree information alternately, but resolve the xml configuration file by client by reading xml configuration file discal patch purpose attribute one by one fully, thereby form the message structure tree that structure is abundant, meaning is complicated, whole process is clear, simple and clear;
3, the xml configuration file is a kind of disclosed structure mark language, especially unusual simple, intuitive concerning the tree structure sign, and can carry different structural informations in transmission over networks, the xml configuration file also has extensibility easily in addition, just can solve the program frequent updating easily or add problems such as deleting program by the attribute of revising the xml configuration file simply, and because the instant messaging of client and server, these modifications can also obtain performance in client termly.
Embodiment
In order to make the features and advantages of the present invention clearer, the present invention is further detailed explanation in conjunction with specific embodiments with reference to the accompanying drawings.
Referring to Fig. 1, real-time live QQLive is an example with instant messaging, is described in detail in the method that the QQLive client forms structure tree.The similar QQGame of QQLive, just in QQLive, the user can enter different rooms and see TV, sees a film, listens to the music, listens to the radio programme etc.
Fig. 1 is the process chart that forms structure tree according to the present invention in client.
Step 101, with the extend markup language (xml that writes, Extensible MarkupLanguage) configuration file is put into HTML (Hypertext Markup Language) (http through overcompression, Hyper TextTransferring Protocol) on the Download Server, the xml configuration file comprises the configuration information of desiring the structure tree of showing in the QQLive client.
Suppose that the xml configuration filename is called config.xml, wherein, this configuration file has defined all properties of desiring at all nodes of the structure tree of QQLive client performance, for example the title of node, image and node are in position in the total tree or the like, after the xml configuration file configuration that name is called config.xml is finished, for client downloads convenient and swift and take up room little, the config.xml configuration file can be carried out the Zip compression of reference format, store into then on the server of supporting the http agreement.Here be not limited to the Zip compress mode, even also can not compress.
Step 102, QQLive client will download to local client through the xml of overcompression configuration file from server, by Zip canonical solution compression algorithm compressed file is unpacked to become famous then to be called the configuration file of config.xml.
Here, the QQLive client utilizes the http agreement to download the configuration file of compression termly from server, so the xml configuration file on the server has any change, all can show in time in the QQLive client, that is to say, any change in QQLive program and/or the room, can realize by directly revising the xml configuration file, these modifications simultaneously can show in time in client, and the modification of xml configuration file and expansion are extremely convenient, as seen, adopt the extensibility that can improve the QQLive client in such a way.In addition, it is mutual with the proprietary protocol of supporting the client and server end to adopt http agreement download configuration file can also avoid developing independent server processes, has reduced the development amount.
Step 103, QQLive client are resolved the config.xml configuration file layer by layer, and distinguish root node and the child node of generating structure tree according to the defined attribute of configuration file.
Because the xml configuration file has defined the attribute of desiring in all clauses and subclauses of the structure tree of client performance, so client only need be read the attribute of each clauses and subclauses, and according to the attribute of clauses and subclauses root node and the child node of generating structure tree get final product layer by layer.
The method of resolving the xml configuration file is a lot, can use analytical tool, also can not use analytical tool, here, adopts CMarkup to resolve class and resolves the config.xml configuration file, and concrete resolving is referring to Fig. 2, and is as follows:
Step 201, search the QQLive label, read the current clauses and subclauses under the QQLive label;
Step 202, judge whether the attribute of the current clauses and subclauses under the QQLive label exists,, illustrate that all clauses and subclauses under the QQLive label are all resolved to finish, withdraw from resolving if the attribute of current clauses and subclauses does not exist; If the attribute of current clauses and subclauses exists, execution in step 203;
Step 203, read current entry tags (tag0), and whether the name attribute (Name) of judging the label of current clauses and subclauses is config, if, illustrate that these clauses and subclauses are global configuration information, can ignore, next clauses and subclauses under the QQLive label as current clauses and subclauses, are returned execution in step 202; If the name attribute of label is not config, illustrate that these clauses and subclauses are programme information, for example TV programme (TV) or broadcast program (Radio), then execution in step 204;
The Sys32TreeView tree of step 204, a Windows of generation, the root node name of tree is the name attribute of current clauses and subclauses, for example QQ is live;
Step 205, QQ is live is the root node of Sys32TreeView structure tree, and its label is not config, illustrating necessarily has child node below live this root node of QQ, then read the sub-clauses and subclauses of the live clauses and subclauses of QQ, for example MediaZone video display district generates MediaZone video display district child node for live time according to attribute root node QQ on structure tree of the sub-clauses and subclauses in MediaZone video display district;
Step 206, read the sub-bar in MediaZone video display district sub-items for information now, according to the next stage node of attribute formation MediaZone video display district child node, this step that circulates is till the sub-items for information of now all of the sub-bar in the MediaZone video display district node that all generating structure is set;
Step 207, judge whether QQ all clauses and subclauses under live all resolve and finish and on the relevant position of structure tree, generate node, if withdraw from; Otherwise the sub-clauses and subclauses of next with QQ under live are returned execution in step 205 as current sub-clauses and subclauses.
Through above step, the client that just can be implemented in QQLive forms a structure tree, similarly, resolved the sub-clauses and subclauses of all QQLive after, withdraw from process of analysis, so just form some structure trees in the QQLive client.Referring to Fig. 3, Fig. 3 is the schematic diagram of the structure tree revealed in client table according to the present invention.Briefly, the process that adopts CMarkup to resolve class parsing config.xml configuration file is exactly that the QQLive client utilizes CMarkup to resolve the configuration informations such as attribute that class reads each clauses and subclauses in the configuration file layer by layer one by one, and generates each node according to the relevant position of configuration information on structure tree of each clauses and subclauses.Thereby adopt this configuration file and do not need client to decode to obtain the information of original ranks file by the method for resolving the generating structure tree, do not need client to carry out logic yet and represent structure tree alternately according to information, only need read the attribute of each clauses and subclauses in the configuration file one by one and on the relevant position of structure tree, generate each node and get final product according to attribute, saved the workload of exploitation client, especially when expansion structure is set, adopt method provided by the invention more efficient and convenient, and extensibility is also strong.
More than be resolve class with CMarkup to resolve the xml configuration file be example, resolving is described, yet, resolve the xml configuration file and be not limited thereto, can also adopt other method or analytical tool that the xml configuration file is resolved.
Can see from the foregoing description, the method of formation structure tree provided by the present invention has been used has the xml configuration file of extensibility easily, through being put into after the overcompression on the server, client decompresses after utilizing the http agreement that compressed file is downloaded to this locality, and utilize CMarkup to resolve class and resolve the xml configuration file, the information of total being set according to the attribute of the structure tree that defines in the xml configuration file shows.
More than, only forming structure tree with the QQLive client in the instant communications field is example, the method that the present invention is formed structure tree has been described in detail, but method provided by the present invention is equally applicable to other field, implementation method and above-described method basically identical in other field are not being given unnecessary details here.
The above is specific embodiments of the invention only, is not in order to limit protection scope of the present invention.