A kind of rich text format of the XMPP based on extension realizes system and method
Technical field
The invention belongs to computer network communication field, and in particular to a kind of rich text lattice of the XMPP based on extension
Formula realizes system and method.
Background technology
Instant message (Instant Messaging, IM) exchange is a kind of real-time internet exchange way.
It is numerous in the IM softwares of China's main flow at present, each possess numerous specific use crowds.For example:The QQ of Tengxun,
The MSN of Microsoft and the Yahoo Manager of Yahoo etc..They each for the commercial interest of itself, respectively using each not
Same protocol format and the communication technology.The disunity of this agreement and underground property, largely constrain IM softwares
Development.
For open and intercommunity the consideration of IM applications, some tissues are just being devoted to the design and standard of general purpose I M agreements
Chemical industry is made.At present, IM puppy parcs mainly have following several:XMPP, IMPP agreements and SIMPLE agreements.Wherein IMPP
The benchmark that protocol definition IM puppy parcs are followed, including service module, functional interface and the data form etc.;XMPP is base
In the puppy parc that XML language is described and defined;SIMPLE is the extension to Session Initiation Protocol, it is supported that IMPS is serviced.XMPP with
SIMPLE is to follow the stipulations of IMPP and formulate, and has in application field and complete realize case.
XMPP is based on XML description languages, as attending and messaging protocol, with very strong autgmentability, higher
The many merits such as security, less format content.The different instant message systems based on this agreement can easily be more realized simultaneously
Interconnecting between system.
With the development of IM, people have been no longer satisfied with simple written communication.The message format of individual character, picture and text are set
And the message content of cyclopentadienyl, the emotion of user could be preferably expressed, meet the demand of user.
The main flow IM clients of current XMPP have the Rooyee Messenger clients of Spark, Pandion and the country
End etc..
Support that situation is as shown in the table for the function of instant message part(√ represents support, × represent and do not support).
Client |
Text message |
Message format |
Picture and text mixing |
Pandion |
√ |
√ |
× |
Spark |
√ |
× |
× |
Rooyeeton |
√ |
√ |
× |
For the country using the most QQ clients of crowd, it can support picture and text mixing, yet with adding for its agreement
Close property, its specific implementation is unknown.
Also there are many softwares to pass through RTF at present(Rich Text Format)Form transmits instant message, for example:
Office Communicator2007 etc..RTF is the cross-platform document format developed by Microsoft, is a kind of similar DOC lattice
Formula(Word document)File, with good compatibility.It has the advantages that as follows:
1. good compatibility is possessed, and most word processor can read and preserve RTF documents.
2. the word in an instant message can be arranged to different forms.
3. picture and text mixing can be realized.
For requiring instant communication software operated quickly and conveniently, all exist in the content of each instant chat big
The form description information of amount, this is undoubtedly a kind of no small burden.
By testing one picture of 120K sizes of stickup in RichText Edition frame, after being translated into RTF data, number
According to length be 10486180byte ≈ 10M, and png format pictures are translated into, after its base64 codings are read afterwards
Length is 164224byte ≈ 160K.The length of RTF data forms is about 64 times of base64 code lengths.Therefore this is for disappearing
It is less suitable for the less strict domestic consumer of the call format of breath.
If picture put transmitting in the message simultaneously, when picture than it is larger when, it will cause the length of message very long;
Network condition be not well in the case of, may Blocking message passage, Consumer's Experience is bad.
The content of the invention
In order to overcome the above-mentioned deficiencies of the prior art, the present invention is provided a kind of transmission based on file and is mutually tied with base64 codings
The picture and text mixing message mode of conjunction, realizes that user is online and offline, the picture and text mixing message of one-to-one and many people
Send and receive.
In order to realize foregoing invention purpose, the present invention is adopted the following technical scheme that:
An aspect of of the present present invention, there is provided a kind of rich text format of the XMPP based on extension realizes system, the system
Including client and server end, it is characterised in that:
The client includes:
Coding/decoding module, for coding and decoding instant message;
Text transceiver module, for sending and receiving text message;With
Picture transceiver module, for sending and receiving pictorial information;
The server end includes:
Information receiving and transmitting processing module, for receiving, forwarding the instant message from client;
Deferred information module, for keeping in text message;With
Picture management module, for preserving and managing pictorial information.
Preferably, the XMPP tissue text message that the coding/decoding module passes through extension;The XMPP includes dividing
Not Biao Shi font, font size, color and font special format " FontFamily ", " FontSize ", " FontColor " and
" FontStyle " label, also including the picture placeholder for recordable picture position.
Preferably, the client includes:
Message input module, for being input into instant message;With
Message is presented module, for showing instant message;
The server includes:Forwarding module, for instant message to be forwarded into destination client;With
SOCKS5 proxy servers.
Another aspect of the present invention, there is provided a kind of rich text format implementation method of the XMPP based on extension, the party
Method is comprised the following steps:
A. coding/decoding module separates the text message and pictorial information in instant message;
B. text message is sent to server by text transceiver module;
C. the pictorial information after treatment is sent to server by picture transceiver module;
D. information receiving and transmitting processing module receive the instant message from client, and classify treatment the message.
Preferably, in the step A, the XMPP tissue text message that the coding/decoding module passes through extension;Should
XMPP include representing respectively font, font size, " FontFamily ", " FontSize " of color and font special format,
" FontColor " and " FontStyle " label;The pictorial information is stored in locally, and in text message with document form
Add picture placeholder in picture position.
Preferably, in the step B, text message is sent to server end information receiving and transmitting processing module, if destination client
Online, then message is handed to destination client by forwarding module, otherwise transfers to deferred information module to be preserved.
Preferably, in the step C, if one-to-one session, then perform following steps:
C-1. picture transceiver module judges whether destination client shows presence to it;If so, performing step C-2;
Otherwise, step C-3 is performed;
C-2. both sides set up the passage that file is transmitted by XEP-0065 the and XEP-0096 agreements of standard;The XEP-
0096 agreement includes file attribute label, for informing that this document is picture file;
C-3. picture file is converted into base64 codings by picture transceiver module, is added to " Data " of " message " section
In label, server is sent to;
If one-to-many session, then picture file is directly converted into base64 codings and is added to " message " section
Sent to server in " Data " label.
Preferably, the step D includes:
D-1. information receiving and transmitting processing module judges the online situation of destination client;If online, step D-2 is performed;Otherwise,
Perform step D-3;
D-2. instant message is forwarded to destination client by information receiving and transmitting processing module by forwarding module;
Instant message is forwarded to picture management module by D-3. information receiving and transmitting treatment;Perform step D-4;
D-4. picture management module judges whether the message is pictorial information, if so, picture file is then saved as, together
Shi Baocun its essential information, when user reaches the standard grade next time, the user is automatically sent to by forwarding module;Otherwise, step is performed
D-5;
D-5. it is that the message is text message, then picture management module forwards it to deferred information module, when under user
It is secondary when reaching the standard grade, the user is automatically sent to by forwarding module.
Preferably, in the step D-4, the essential information includes:Image ID, picture name, the pure JID of recipient and figure
The storing path of piece.
Compared with prior art, the beneficial effects of the present invention are:
1. using open XMPP, with good autgmentability and intercommunity.
2. when message receiver is online, come the picture text in individually sending instant message by the way of file transmission
Part, realizes that the separation of picture and text sends;Prevent picture excessive, Blocking message passage.
3. in other side recipient is not online or many people chat, the figure in instant message is sent using base64 codings
Piece, efficiency is of a relatively high.
Brief description of the drawings
Fig. 1 is that the rich text format of XMPP of the present invention based on extension realizes system module figure;
Fig. 2 is message transmission flow figure when one-to-one chat correspondent is online in the embodiment of the present invention;
Fig. 3 is message transmission flow figure when one-to-one chat correspondent is not online in the embodiment of the present invention;
Fig. 4 is many people's chat messages transmission flow figures in the embodiment of the present invention;
Specific embodiment
The present invention is described in further detail below in conjunction with the accompanying drawings.
As shown in figure 1, system of the invention is made up of client and server two parts, wherein client is input into by message
Module, message are presented module, coding/decoding module, text transceiver module and the part of picture transceiver module five composition:
Message input module:For the input of client instant message;
Message is presented module:For the display of instant message;
Coding/decoding module:Coding and decoding function for instant message are realized;Including picture and the volume of word
Code with decoding, the coding of text message format with decode etc.;
Text transceiver module:For the transmission and reception of instant message text messages;
Picture transceiver module:For the transmission and reception of pictorial information in instant message;When can be between both sides' client
In the case of setting up P2P connections, picture file is preferentially sent using direct-connected mode;Otherwise sent out by the way of server agent
Send;
Server end is main by messaging interface, deferred information module, picture management module, the part group of forwarding module four
Into:
Information receiving and transmitting processing module:For the instant message for receiving and forwarding client to send, and various message
Respective logic treatment;
Deferred information module:When opposite end client is not online, for preserving message;And will after destination client is reached the standard grade
The message is sent to the client;
Picture management module:For preserving and the pictorial information in managing instant messages;
Forwarding module:The Jid of the recipient in message, forwarding instant message is to destination client;
Instant message in the system can be divided into two kinds of situations of man-to-man instant message and many people's instant messages, root
Different sending methods will be used according to different situations, concrete methods of realizing is as follows.
(One)One-to-one instant message
As Figure 2-3, comprise the following steps that:
Step one:Customer end A sends instant message to customer end B;The picture and text that sender will be input into message input module
The form of mixing message and message takes out, and transfers to the message coding/decoding module of client to process.
Step 2:Coding/decoding module carries out coded treatment to the instant message of picture and text mixing, separates picture therein and text
This, picture is stored in locally with document form(Picture name requirement uniqueness, is named using " time _ picture number " and preserved);
And add picture placeholder, the relative position for recording picture and text in the position where picture in text message.After coding
Text message is added to<message/>Section<body>In label, while<message/>Added in section<FontFamily
>、<FontSize>、<FontColor>With<FontStyle>Four labels, represent font, font size, color and font respectively
Special format (underscore, italic, runic etc.).By what is generated after coding<message/>Section gives the transmission of text transceiver module,
Picture transceiver module is transferred to process picture file.
Step 3:Text message is directly sent to server by text transceiver module, and message is routed into target by server
Client;Picture transceiver module judges whether customer end B is online, and whether online refers to customer end B in customer end A herein
The whether online state for being presented, rather than customer end B is actual whether online.If performing step 4 online;Otherwise hold
Row step 6;
Step 4:Both sides are acted on behalf of according to XEP-0065 the and XEP-0096 agreements of standard by the Socks5 of server end
Module sets up the passage of file transmission;Wherein need to notify that other side receives the standard of file in XEP-0096 agreements<iq>Section
In, addition<msg_picture xmlns=’service.msg.picture’/>Label.Inform this transmission of destination client
File be picture file in instant message, without pointing out user, directly receive this document.Perform step 5.
Step 5:The text transceiver module of customer end B, after receiving the text message for including picture placeholder, can root
Judge whether the picture has been conveyed through coming according to the picture name in text message;If it is directly display.Otherwise will be
The interim picture of the position display " picture is downloaded " of picture placeholder.It is artwork that picture is changed after the completion of picture transmission
Piece.Perform step 7.
Step 6:Text message is directly sent to server by text transceiver module, and message is routed into target by server
Client;Picture file is converted into base64 codings by picture transceiver module, is added to<message>Section<Data>Mark
In label, other side is sent to.Customer end B reach the standard grade after by receive text message and the picture file that customer end A sends, by compile solve
Code module shows after reconfiguring in message is presented module.Perform step 7.
Step 7:Terminate.
(Two)Many people's instant messages
As shown in figure 4, comprising the following steps that:
Step one:Customer end A is to transmission instant message in UC groups (GroupUC);Message coding/decoding module is input into from message
The instant message of picture and text mixing and the format information of message are taken out in module, and is processed.
Step 2:Coding/decoding module carries out coded treatment to the instant message of picture and text mixing, separates picture therein and text
This, picture is stored in locally with document form(Picture name requirement uniqueness, is named using " time _ picture number " and preserved);
And add picture placeholder, the relative position for recording picture and text in the position where picture in text message.After coding
Text message is added to<message/>Section<body>In label, while<message/>Added in section<FontFamily
>、<FontSize>、<FontColor>With<FontStyle>Four labels, represent font, font size, color and font respectively
Special format (underscore, italic, runic etc.).By what is generated after coding<message/>Section gives the transmission of text transceiver module,
Picture transceiver module is transferred to process picture file.
Step 3:Picture file is converted into base64 codings by picture transceiver module, is added to<message>Section<
Data>In label, server is sent to.When member is online in group, then the picture and text sent by server are directly received
Message, transfers to message that module is presented and shows after being processed by the coding/decoding module of local terminal;When member is not online, after logging in next time i.e.
The offline picture and offline text message sent by group's server can be received;Disappearing after being reconfigured by coding/decoding module
Breath shows during module is presented.
Step 4:Terminate.
(Three)Server end flow
Step one:When server receives the message that client is sended over, according to<message>The type attributes of section,
If type==chat performs step 2;If type==groupchat performs step 5;
Step 2:Man-to-man instant message.According to<message>The to attributes of section, judge whether recipient is online, this
Place it is whether online be it is real whether online, server can be acquisition.If recipient online if perform step 3, it is no
Then perform step 4;
Step 3:Message is directly routed to by recipient by forwarding module;
Step 4:The message is processed by the picture management module of server end;If<message>Included in section<Data>
Label, then it represents that the message is the picture file in instant message, will<Data>Content in label preserves into picture file, text
Part is entitled<FileName>Content in label;The essential information of the picture, including ID, picture name are preserved in database simultaneously
Storing path of title, the pure JID of recipient and picture etc., searches after being reached the standard grade for recipient and uses.When server sends picture
After the completion of, delete the essential information of the picture in the picture and database.If<message>Do not include in section<Data>Mark
Sign, represent that this message is text message;Be saved as deferred information, after waiting the user to reach the standard grade next time, by server from
Line message module is automatically transmitted to the user.Perform step 8.
Step 5:Many people's instant messages.All members in searching loop this group, if group members are online, perform step
Six;Otherwise perform step 7;
Step 6:Message is directly routed to by the member by forwarding module;
Step 7:The message is processed by the picture management module of server end;If<message>Included in section<Data>
Label, then it represents that the message is the picture file in instant message, will<Data>Content in label preserves into picture file, text
Part is entitled<FileName>Content in label;The essential information of the picture, including ID, picture name are preserved in database simultaneously
Storing path of title, the pure JID of recipient, time and picture etc., searches after being reached the standard grade next time for group members and uses.Server will scheme
After piece is sent completely, picture pictorial information corresponding with the member in database is deleted, when all of offline member succeeds
After receiving the picture, this picture file on server is deleted.If<message>Do not include in section<Data>Label, represents
This message is text message;Deferred information is saved as, after waiting the group members to reach the standard grade next time, by the deferred information of server
Module is automatically transmitted to the user.
Step 8:Terminate.
The picture management module of server will regularly clear up offline message and picture simultaneously, when offline message and figure
Piece has exceeded the number of days of setting, and server can be deleted.Save server storage.
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention rather than its limitations, to the greatest extent
Pipe has been described in detail with reference to above-described embodiment to the present invention, and those of ordinary skill in the art should be understood:Still
Specific embodiment of the invention can be modified or equivalent, and without departing from any of spirit and scope of the invention
Modification or equivalent, it all should cover in the middle of scope of the presently claimed invention.