CN108737246A - Message issuing method, device, storage medium and server - Google Patents
Message issuing method, device, storage medium and server Download PDFInfo
- Publication number
- CN108737246A CN108737246A CN201810426840.2A CN201810426840A CN108737246A CN 108737246 A CN108737246 A CN 108737246A CN 201810426840 A CN201810426840 A CN 201810426840A CN 108737246 A CN108737246 A CN 108737246A
- Authority
- CN
- China
- Prior art keywords
- message
- sequence number
- placeholder
- chain
- memory
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/04—Real-time or near real-time messaging, e.g. instant messaging [IM]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/06—Message adaptation to terminal or network requirements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
- H04L51/214—Monitoring or handling of messages using selective forwarding
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The present invention provides a kind of message issuing method of instant messaging, includes the following steps:The message of instant messaging is obtained, the message is saved in memory by the zset data structures based on Redis, forms message chain;The instruction for deleting message is received, deletion message corresponding sequence number in the message chain is obtained;Message chain corresponding position is set as placeholder according to the sequence number;According to the message chain issuing message.In embodiments of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity leakage detection will not fill a vacancy again.The present invention also provides transmitting apparatus, storage medium and servers under a kind of message of instant messaging.
Description
Technical field
The present invention relates to message processing technique fields, specifically, the present invention relates to a kind of message of instant messaging to issue
Method, apparatus, storage medium and server.
Background technology
Current social software almost all of on the market can be all provided in chat feature based on one-to-one chat feature,
Some offer message recalls function, and the message just disappears in this way can not be seen again.How to ensure message succession and
How to ensure that new message chain can normally string together an always research topic after revocation message.Equally, different
The storage of the server of product and the difference of algorithm can lead to the totally different of efficiency and performance.
In the existing merging method to message, message is given every there are in database table by increasing ID certainly in server
One message generates unique sequence number, and each message is a session by unique sequence numbers series connection, if A deletes one
Message, then server can delete the corresponding data-base recording of this message SN;User needs when message is gone in client drawing
Range query is carried out by SQL.Belong to disk I/O operation from increasing ID and range query based on database, to the treatability of message
It can be bad;Deleting message causes the sequence number of message discontinuous, to client when the more equipment of client pull, can not confirm and pull
Message data have loss or server communication data inherently when have defect, may carry out it is secondary pull, causing need not
The expense wanted is caused stress to server.
Invention content
The present invention is directed to the shortcomings that existing way, it is proposed that a kind of message issuing method of instant messaging, device and service
Device, after being set as placeholder by will delete message, client sees issuing message, and there are placeholders to identify there are filling-up hole,
Without removing verification missing information, solve the problems, such as to be not necessarily to leakage detection.
The present invention provides a kind of message issuing method of instant messaging, includes the following steps:
The message of instant messaging is obtained, the message is saved in memory by the zset data structures based on Redis, and formation disappears
Cease chain;
The instruction for deleting message is received, deletion message corresponding sequence number in the message chain is obtained;
Message chain corresponding position is set as placeholder according to the sequence number;
According to the message chain issuing message.
Preferably, the composition of the message includes:In message sender, message receiver, message content types and message
Hold;The placeholder is identified range using two nodes of min and max.
Preferably, the message is saved in memory by the zset data structures based on Redis, forms message chain,
Including:
Binary message is converted the message to, and is stored in memory according to the storage organization of ordered set, is obtained
The corresponding element of the binary message;
Corresponding binding is carried out using unique score to each element;
The sequence number of the ordered set is preserved using score, realizes and the binary message is converted into message chain
Form.
Preferably, it is to the querying command of the message chain:zrangebyscoreabmsgs<minSeq><maxSeq
>;
Wherein, zrangebyscore indicates the order by Score Inquiry result, disappearing between abmsgs expression preservations ab
Chain is ceased, minSeq indicates that minimum sequence number, maxSeq indicate maximum sequence number.
Preferably, described that message chain corresponding position is set as according to the sequence number by placeholder, including:
Position corresponding with the sequence number is searched in the message chain, addition is same again at the location
The element of score forms placeholder.
Preferably, the addition order of the element for adding same score again is:zaddabmsgs seq1<
place_holder_msg>;
Wherein, zadd indicates to add the order of the element of same score, and abmsgs indicates to preserve the message chain between ab,
Seq1 indicates that sequence number, place_holder_msg indicate placeholder.
Preferably, the minmal sequence number of the placeholder and maximum sequence number are the corresponding sequence number of the placeholder.
Preferably, it is described according to the message chain issuing message before, further include:
Confirming the message chain, there are at least two continuous placeholders, and described at least two continuous occupy-places are met
And at a placeholder.
Preferably, described that described at least two continuous placeholders are merged into a placeholder, including:
Obtain the maximum sequence number of described at least two continuous placeholders;
Obtain the minmal sequence number of described at least two continuous placeholders;
A placeholder is formed according to the maximum sequence number and the minmal sequence number.
The present invention also provides transmitting apparatus under a kind of message of instant messaging comprising:
Message preserving module:Message for obtaining instant messaging, the zset data structures based on Redis are the message
It is saved in memory, forms message chain;
Sequence number acquisition module:For receiving the instruction for deleting message, the deletion message is obtained in the message chain
In corresponding sequence number;
Placeholder setup module:For message chain corresponding position to be set as placeholder according to the sequence number;
Message issues module:For according to the message chain issuing message.
Preferably, the message preserving module includes:
Storage unit:For converting the message to binary message, and according to the storage organization of ordered set including
Middle storage is deposited, the corresponding element of the binary message is obtained;
Binding unit:For carrying out corresponding binding using unique score to each element;
Conversion unit:Sequence number for being preserved the ordered set using score is realized and turns the binary message
It is changed to the form of message chain.
Preferably, described to further include before message issues module:
Placeholder merging module:For confirming the message chain, there are at least two continuous placeholders, described in extremely
Few two continuous placeholders are merged into a placeholder.
Preferably, placeholder merging module includes:
First acquisition unit:Maximum sequence number for obtaining described at least two continuous placeholders;
Second acquisition unit:Minmal sequence number for obtaining described at least two continuous placeholders;
Recomposition unit:For forming a placeholder according to the maximum sequence number and the minmal sequence number.
The present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, which is handled
Device realizes message issuing method as in one of claimed in any of claims 1 to 9 when executing.
The present invention also provides a kind of servers comprising:
One or more processors;
Memory;
One or more application program, wherein one or more of application programs are stored in the memory and quilt
It is configured to be executed by one or more of processors, one or more of programs are configured to:It executes according to claim 1
To the message issuing method described in any one of 9.
In specific implementation process of the present invention, by obtaining the message of instant messaging, the zset data structures based on Redis
The message is saved in memory, forms message chain;The instruction for deleting message is received, the deletion message is obtained and disappears described
Cease corresponding sequence number in chain;Message chain corresponding position is set as placeholder according to the sequence number;According to institute
State message chain issuing message.All operations are completed in memory, and it is very fast to execute speed;Client is issued in reception to disappear
It finds that placeholder is the data that may recognize that there are filling-up hole in breath, just believes that issuing message authenticity leakage detection will not fill a vacancy again.
The additional aspect of the present invention and advantage will be set forth in part in the description, these will become from the following description
Obviously, or practice through the invention is recognized.
Description of the drawings
Above-mentioned and/or additional aspect and advantage of the invention will become from the following description of the accompanying drawings of embodiments
Obviously and it is readily appreciated that, wherein:
Fig. 1 is the flow diagram of the message issuing method of the instant messaging in first embodiment of the invention;
Fig. 2 is the flow diagram of the message issuing method of the instant messaging in second embodiment of the invention;
Fig. 3 is that message is preserved in memory and forms the flow diagram of message chain by the present invention;
Fig. 4 is that the present invention merges at least two continuous placeholders the flow diagram for becoming a placeholder;
Fig. 5 be the instant messaging in third embodiment of the invention message under transmitting apparatus structure composition schematic diagram;
Fig. 6 be the instant messaging in fourth embodiment of the invention message under transmitting apparatus structure composition schematic diagram;
Fig. 7 is that the server composed structure of the message issuing method of the execution instant messaging in fifth embodiment of the invention is shown
It is intended to.
Specific implementation mode
The embodiment of the present invention is described below in detail, examples of the embodiments are shown in the accompanying drawings, wherein from beginning to end
Same or similar label indicates same or similar element or element with the same or similar functions.Below with reference to attached
The embodiment of figure description is exemplary, and is only used for explaining the present invention, and is not construed as limiting the claims.
Those skilled in the art of the present technique are appreciated that unless expressly stated, singulative " one " used herein, " one
It is a ", " described " and "the" may also comprise plural form.It is to be further understood that is used in the specification of the present invention arranges
It refers to there are the feature, integer, step, operation, element and/or component, but it is not excluded that presence or addition to take leave " comprising "
Other one or more features, integer, step, operation, element, component and/or their group.It should be understood that when we claim member
Part is " connected " or when " coupled " to another element, it can be directly connected or coupled to other elements, or there may also be
Intermediary element.In addition, " connection " used herein or " coupling " may include being wirelessly connected or wirelessly coupling.It is used herein to arrange
Diction "and/or" includes that the whole of one or more associated list items or any cell are combined with whole.
Those skilled in the art of the present technique are appreciated that unless otherwise defined, all terms used herein (including technology art
Language and scientific terminology), there is meaning identical with the general understanding of the those of ordinary skill in fields of the present invention.Should also
Understand, those terms such as defined in the general dictionary, it should be understood that have in the context of the prior art
The consistent meaning of meaning, and unless by specific definitions as here, the meaning of idealization or too formal otherwise will not be used
To explain.
Embodiment one:
Referring to Fig. 1, Fig. 1 is the flow signal of the message issuing method of the instant messaging in first embodiment of the invention
Figure.
As shown in Figure 1, a kind of message issuing method of instant messaging, includes the following steps:
S11:The message of instant messaging is obtained, the message is saved in memory, shape by the zset data structures based on Redis
At message chain;
Instant messaging is to refer to send and receive the business such as internet message immediately, and the message of instant messaging is a direction
The message that another party sends, when user carries out instant messaging, Instant Messenger can be obtained in real time by providing the server of instant messaging
The message of letter, the message contain message sender, message receiver and message content types and message content, and to i.e.
The message of Shi Tongxin is formed by placeholder using two nodes of min and max to carry out scope identifier.
Scope identifier wherein is carried out using two nodes of min and max to the definition of instant communication message and placeholder
It is by following Implementation of pseudocode:
Above-mentioned pseudocode describe a Message (message) be constitute, including sender, recipient and
Content_type types and content contents, normal message by the type (type) and content (content) of itself come
It indicates;The type (type) that placeholder has itself special distinguishes message, while the data structure of message itself
PlaceHolderMessage indicates range by two nodes of min and max, this is multiple placeholders in subsequent step
It is continuous merging provide guarantee.
The message is saved in memory by the zset data structures based on Redis, forms message chain.
In embodiments of the present invention, storage is based on the zeset in Redis (key-value storage systems (database))
(ordered set), zeset are a set that can be sorted, and in interior of a set, there are one only by each element member
One score score is corresponding to it binding, you can the binary message of specific message content is preserved by element member,
Seq (sequence number) is preserved with score and then realizes the storage of chain of messages strips.
Querying command to chain storage form message is:zrangebyscoreabmsgs<minSeq><maxSeq>;
Wherein, zrangebyscore indicates the order by Score Inquiry result, disappearing between abmsgs expression preservations ab
Chain is ceased, minSeq indicates that minimum sequence number, maxSeq indicate that maximum sequence number, the order can return between two values
The member (element) of all score (score) and the score (score) bindings.
Wherein, referring to Fig. 3, Fig. 3 is the flow signal of the invention for preserving in memory message and forming message chain
Figure.
As shown in figure 3, detailed step is as follows:
S111:Binary message is converted the message to, and is stored in memory according to the storage organization of ordered set,
Obtain the corresponding element of the binary message;
Storage message in memory is needed to be converted to binary message first and could be stored, and therefore, is converted the message to
Binary message, by zset data structure storages to memory of the binary message based on Redis, Redis key-value
Storage system (database), zset are ordered set, which stores in memory according to the structure of ordered set, should
Binary message can use a unique element to carry out corresponding relationship in memory, can be got by the binary message
The corresponding element of the message.
S112:Corresponding binding is carried out using unique score to each element;
Inside ordered set in memory storage, to each element, all bound using a unique score,
Unique Score Inquiry to corresponding element can be passed through in this way, you can corresponding message is got by corresponding element.
S113:The sequence number of the ordered set is preserved using score, realizes and the binary message is converted into message
The form of chain.
The score of binding is corresponded to using element to preserve the sequence number in ordered set, because the sequence number in ordered set is
Continuously, binary message can be converted on message chain by forming continuous chain after being preserved using score.
S12:The instruction for deleting message is received, deletion message corresponding sequence number in the message chain is obtained;
In the both sides of instant messaging, a direction another party send message after, find send after message there may be
When description is wrong or chooses words inappropriately, request deletes or recalls transmitted message, sends out deletion or the instruction of revocation messages first,
There is provided for user both sides instant messaging server receive deletion or the instruction of revocation messages after, obtained in message chain
User needs the message deleted or recalled corresponding sequence number in message chain.
S13:Message chain corresponding position is set as placeholder according to the sequence number;
Specifically, searching position corresponding with the sequence number in the message chain, at the location again
The element of same score is added, placeholder is formed.
In specific implementation process, after message sender is deleted or revocation messages instruct, database deletes corresponding disappear
Breath then obtains and deletes the corresponding sequence number of message, corresponding deletion is searched in zset (ordered set) then in the database
Message, then from new addition and originally in the member of the same score of zset (ordered set);Weight is newly added to pass through order
It realizes, order is as follows:zaddabmsgs seq1<place_holder_msg>;
Wherein, zadd indicates to add the order of the element of same score, and abmsgs indicates to preserve the chain of messages between ab,
Seq1 indicates that sequence number, place_holder_msg indicate placeholder.
It is formed after placeholder, minmal sequence number and the maximum sequence number of the placeholder are the corresponding sequence of the placeholder
Row number.
S14:According to the message chain issuing message.
In specific implementation process, server there will be the message chain of placeholder to request issuing message user issue
Message.
It should be noted that there are A, party B-subscriber both sides or more users sides to exist jointly in instant messaging, logical
When crossing instant messaging transmission message, if the message that a side has sent is removed there may be improper or other reasons, request is stated
It returns message or deletes message, another party is when asking issuing message, i.e. the message to deleting or recalling through the above steps
Placeholder is arranged in the position at place so that message chain keeps continuous, and another party of issuing message is asked to may know that other side has
Message is recalled or deleted, not will be considered that information drop-out.
In specific implementation process of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client
It finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity will not be again
Secondary leakage detection is filled a vacancy.
Embodiment two:
Referring to Fig. 2, Fig. 2 is the flow signal of the message issuing method of the instant messaging in second embodiment of the invention
Figure.
As shown in Fig. 2, a kind of message issuing method of instant messaging, includes the following steps:
S21:The message of instant messaging is obtained, the message is saved in memory, shape by the zset data structures based on Redis
At message chain;
Instant messaging is to refer to send and receive the business such as internet message immediately, and the message of instant messaging is a direction
The message that another party sends, when user carries out instant messaging, Instant Messenger can be obtained in real time by providing the server of instant messaging
The message of letter, the message contain message sender, message receiver and message content types and message content, and to i.e.
The message of Shi Tongxin is formed by placeholder using two nodes of min and max to carry out scope identifier.
Scope identifier wherein is carried out using two nodes of min and max to the definition of instant communication message and placeholder
It is by following Implementation of pseudocode:
Above-mentioned pseudocode describe a Message (message) be constitute, including sender, recipient and
Content_type types and content contents, normal message by the type (type) and content (content) of itself come
It indicates;The type (type) that placeholder has itself special distinguishes message, while the data structure of message itself
PlaceHolderMessage indicates range by two nodes of min and max, this is multiple placeholders in subsequent step
It is continuous merging provide guarantee.
The message is saved in memory by the zset data structures based on Redis, forms message chain.
In embodiments of the present invention, storage is based on the zeset in Redis (key-value storage systems (database))
(ordered set), zeset are a set that can be sorted, and in interior of a set, there are one only by each element member
One score score is corresponding to it binding, you can the binary message of specific message content is preserved by element member,
Seq (sequence number) is preserved with score and then realizes the storage of chain of messages strips.
Querying command to chain storage form message is:zrangebyscoreabmsgs<minSeq><maxSeq>;
Wherein, zrangebyscore indicates the order by Score Inquiry result, disappearing between abmsgs expression preservations ab
Chain is ceased, minSeq indicates that minimum sequence number, maxSeq indicate that maximum sequence number, the order can return between two values
The member (element) of all score (score) and the score (score) bindings.
Wherein, referring to Fig. 3, Fig. 3 is the flow signal of the invention for preserving in memory message and forming message chain
Figure.
As shown in figure 3, detailed step is as follows:
S111:Binary message is converted the message to, and is stored in memory according to the storage organization of ordered set,
Obtain the corresponding element of the binary message;
Storage message in memory is needed to be converted to binary message first and could be stored, and therefore, is converted the message to
Binary message, by zset data structure storages to memory of the binary message based on Redis, Redis key-value
Storage system (database), zset are ordered set, which stores in memory according to the structure of ordered set, should
Binary message can use a unique element to carry out corresponding relationship in memory, can be got by the binary message
The corresponding element of the message.
S112:Corresponding binding is carried out using unique score to each element;
Inside ordered set in memory storage, to each element, all bound using a unique score,
Unique Score Inquiry to corresponding element can be passed through in this way, you can corresponding message is got by corresponding element.
S113:The sequence number of the ordered set is preserved using score, realizes and the binary message is converted into message
The form of chain.
The score of binding is corresponded to using element to preserve the sequence number in ordered set, because the sequence number in ordered set is
Continuously, binary message can be converted on message chain by forming continuous chain after being preserved using score.
S22:The instruction for deleting message is received, deletion message corresponding sequence number in the message chain is obtained;
In the both sides of instant messaging, a direction another party send message after, find send after message there may be
When description is wrong or chooses words inappropriately, request deletes or recalls transmitted message, sends out deletion or the instruction of revocation messages first,
There is provided for user both sides instant messaging server receive deletion or the instruction of revocation messages after, obtained in message chain
User needs the message deleted or recalled corresponding sequence number in message chain.
S23:Message chain corresponding position is set as placeholder according to the sequence number;
Specifically, searching position corresponding with the sequence number in the message chain, at the location again
The element of same score is added, placeholder is formed.
In specific implementation process, after message sender is deleted or revocation messages instruct, database deletes corresponding disappear
Breath then obtains and deletes the corresponding sequence number of message, corresponding deletion is searched in zset (ordered set) then in the database
Message, then from new addition and originally in the member of the same score of zset (ordered set);Weight is newly added to pass through order
It realizes, order is as follows:zaddabmsgs seq1<place_holder_msg>;
Wherein, zadd indicates to add the order of the element of same score, and abmsgs indicates to preserve the chain of messages between ab,
Seq1 indicates that sequence number, place_holder_msg indicate placeholder.
It is formed after placeholder, minmal sequence number and the maximum sequence number of the placeholder are the corresponding sequence of the placeholder
Row number.
S24:Confirming the message chain, there are at least two continuous placeholders, described at least two continuous occupy-places
Symbol is merged into a placeholder;
In specific implementation process, confirmed by way of traversing the message chain in the message chain with the presence or absence of at least
Two continuous placeholders are directly entered S25 if being not present, and if it exists, are then closed at least two continuous placeholders
And it is merged into a new placeholder.
At least two continuous placeholders are merged, for for using the maximum sequence in at least two continuous placeholder message
The maximum sequence number of row number placeholder message the newest, that is, it is new to take the max_seq at least two continuous placeholder message
Placeholder message max_seq;Minmal sequence number in at least two continuous placeholder message is that new placeholder disappears
The minmal sequence number of breath, that is, it is the min_ of new placeholder message to take the min_seq at least two continuous placeholder message
seq;A new placeholder message, the new placeholder are become at least two continuous placeholder message coalescings to realize
The expression of message is ranging from originally for the maximum sequence number and minmal sequence number of at least two continuous placeholder message.
It is specific as follows:
The case where table 1 is the message chain of the A stored in zset and B is from left to right incremented by, i.e. the message of time order and function,
The message of wherein 101,103,104 and 107 is deleted (either A or B delete)
Table 1
A new placeholder message is become to 103 and No. 104 message, which uses min_seq=
103, max_seq=104 sequence numbers identify, this is just called filling-up hole, and client takes the data with hole and is known that this load
Seq ranges among normal messages are strictly no data, just no longer go whether server requests authentication has missing information.
Or it is another example:
If 100 be a normal message, then 100 this normal messages are expressed as member (100,100), if 97,
98,99 3 normal message are all deleted, then can be merged into member (97,99).
Wherein, referring to Fig. 4, Fig. 4 is the present invention becomes a placeholder at least two continuous placeholders merging
Flow diagram.
As shown in figure 4, detailed step is as follows:
S241:Obtain the maximum sequence number of described at least two continuous placeholders;
To at least two continuous placeholder message using the maximum sequence number in at least two continuous placeholder message, i.e.,
For the max_seq for obtaining at least two continuous placeholder message.
S242:Obtain the minmal sequence number of described at least two continuous placeholders;
Minmal sequence number in at least two continuous placeholder message as obtains at least two continuous placeholders and disappears
Min_seq in breath.
S243:A placeholder is formed according to the maximum sequence number and the minmal sequence number.
At least two continuous placeholders are merged into a new placeholder, then need this new placeholder most
Small and maximum sequence number is then used to get the sequence number of the minimum and maximum of new placeholder in S241 and S242
The minimum and maximum set of serial numbers is at a new placeholder.103 and 104 are such as merged into a new placeholder message, then
It is member (103,104) that the new placeholder message, which uses min_seq=103, max_seq=104 sequence numbers mark,.
S25:According to the message chain issuing message.
In specific implementation process, server there will be the message chain of placeholder to request issuing message user issue
Message.
In specific implementation process of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client
It finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity will not be again
Secondary leakage detection is filled a vacancy;The number for issuing hole can be greatly reduced based on the scheme for merging continuous loophole, reduce bandwidth occupancy.
Embodiment three:
Referring to Fig. 5, Fig. 5 be the instant messaging in third embodiment of the invention message under the structure composition of transmitting apparatus show
It is intended to.
As shown in figure 5, transmitting apparatus under a kind of message of instant messaging comprising:
Message preserving module 11:Message for obtaining instant messaging, the zset data structures based on Redis disappear described in
Breath is saved in memory, forms message chain;
Instant messaging is to refer to send and receive the business such as internet message immediately, and the message of instant messaging is a direction
The message that another party sends, when user carries out instant messaging, Instant Messenger can be obtained in real time by providing the server of instant messaging
The message of letter, the message contain message sender, message receiver and message content types and message content, and to i.e.
The message of Shi Tongxin is formed by placeholder using two nodes of min and max to carry out scope identifier.
Scope identifier wherein is carried out using two nodes of min and max to the definition of instant communication message and placeholder
It is by following Implementation of pseudocode:
Above-mentioned pseudocode describe a Message (message) be constitute, including sender, recipient and
Content_type types and content contents, normal message by the type (type) and content (content) of itself come
It indicates;The type (type) that placeholder has itself special distinguishes message, while the data structure of message itself
PlaceHolderMessage indicates range by two nodes of min and max, this is multiple placeholders in subsequent step
It is continuous merging provide guarantee.
The message is saved in memory by the zset data structures based on Redis, forms message chain.
In embodiments of the present invention, storage is based on the zeset in Redis (key-value storage systems (database))
(ordered set), zeset are a set that can be sorted, and in interior of a set, there are one only by each element member
One score score is corresponding to it binding, you can the binary message of specific message content is preserved by element member,
Seq (sequence number) is preserved with score and then realizes the storage of chain of messages strips.
Querying command to chain storage form message is:zrangebyscoreabmsgs<minSeq><maxSeq>;
Wherein, zrangebyscore indicates the order by Score Inquiry result, disappearing between abmsgs expression preservations ab
Chain is ceased, minSeq indicates that minimum sequence number, maxSeq indicate that maximum sequence number, the order can return between two values
The member (element) of all score (score) and the score (score) bindings.
Wherein, which further includes:
Storage unit:For converting the message to binary message, and according to the storage organization of ordered set including
Middle storage is deposited, the corresponding element of the binary message is obtained;
Storage message in memory is needed to be converted to binary message first and could be stored, and therefore, is converted the message to
Binary message, by zset data structure storages to memory of the binary message based on Redis, Redis key-value
Storage system (database), zset are ordered set, which stores in memory according to the structure of ordered set, should
Binary message can use a unique element to carry out corresponding relationship in memory, can be got by the binary message
The corresponding element of the message.
Binding unit:For carrying out corresponding binding using unique score to each element;
Inside ordered set in memory storage, to each element, all bound using a unique score,
Unique Score Inquiry to corresponding element can be passed through in this way, you can corresponding message is got by corresponding element.
Conversion unit:Sequence number for being preserved the ordered set using score is realized and turns the binary message
It is changed to the form of message chain.
The score of binding is corresponded to using element to preserve the sequence number in ordered set, because the sequence number in ordered set is
Continuously, binary message can be converted on message chain by forming continuous chain after being preserved using score.
Sequence number acquisition module 12:For receiving the instruction for deleting message, the deletion message is obtained in the chain of messages
Corresponding sequence number in item;
In the both sides of instant messaging, a direction another party send message after, find send after message there may be
When description is wrong or chooses words inappropriately, request deletes or recalls transmitted message, sends out deletion or the instruction of revocation messages first,
There is provided for user both sides instant messaging server receive deletion or the instruction of revocation messages after, obtained in message chain
User needs the message deleted or recalled corresponding sequence number in message chain.
Placeholder setup module 13:For message chain corresponding position to be set as occupy-place according to the sequence number
Symbol;
Specifically, searching position corresponding with the sequence number in the message chain, at the location again
The element of same score is added, placeholder is formed.
In specific implementation process, after message sender is deleted or revocation messages instruct, database deletes corresponding disappear
Breath then obtains and deletes the corresponding sequence number of message, corresponding deletion is searched in zset (ordered set) then in the database
Message, then from new addition and originally in the member of the same score of zset (ordered set);Weight is newly added to pass through order
It realizes, order is as follows:zaddabmsgs seq1<place_holder_msg>;
Wherein, zadd indicates to add the order of the element of same score, and abmsgs indicates to preserve the chain of messages between ab,
Seq1 indicates that sequence number, place_holder_msg indicate placeholder.
It is formed after placeholder, minmal sequence number and the maximum sequence number of the placeholder are the corresponding sequence of the placeholder
Row number.
Message issues module 14:For according to the message chain issuing message.
In specific implementation process, server there will be the message chain of placeholder to request issuing message user issue
Message.
In specific implementation process of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client
It finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity will not be again
Secondary leakage detection is filled a vacancy.
Example IV:
Referring to Fig. 6, Fig. 6 be the instant messaging in fourth embodiment of the invention message under the structure composition of transmitting apparatus show
It is intended to.
As shown in fig. 6, transmitting apparatus under a kind of message of instant messaging, including:
Message preserving module 21:Message for obtaining instant messaging, the zset data structures based on Redis disappear described in
Breath is saved in memory, forms message chain;
Sequence number acquisition module 22:For receiving the instruction for deleting message, the deletion message is obtained in the chain of messages
Corresponding sequence number in item;
Placeholder setup module 23:For message chain corresponding position to be set as occupy-place according to the sequence number
Symbol;
The specific implementation mode of above-mentioned message preserving module 21, sequence number acquisition module 22, placeholder setup module 23
Can be with reference implementation example one to embodiment three, details are not described herein.
Placeholder merging module 24:For confirming the message chain, there are at least two continuous placeholders, described in
At least two continuous placeholders are merged into a placeholder.
In specific implementation process, confirmed by way of traversing the message chain in the message chain with the presence or absence of at least
Two continuous placeholders are directly entered message and issue 25 direct issuing message of module, and if it exists, then to extremely if being not present
Few two continuous placeholders merge, and are merged into a new placeholder.
At least two continuous placeholders are merged, for for using the maximum sequence in at least two continuous placeholder message
The maximum sequence number of row number placeholder message the newest, that is, it is new to take the max_seq at least two continuous placeholder message
Placeholder message max_seq;Minmal sequence number in at least two continuous placeholder message is that new placeholder disappears
The minmal sequence number of breath, that is, it is the min_ of new placeholder message to take the min_seq at least two continuous placeholder message
seq;A new placeholder message, the new placeholder are become at least two continuous placeholder message coalescings to realize
The expression of message is ranging from originally for the maximum sequence number and minmal sequence number of at least two continuous placeholder message.
It is specific as follows:
The case where table 1 is the message chain of the A stored in zset and B is from left to right incremented by, i.e. the message of time order and function,
The message of wherein 101,103,104 and 107 is deleted (either A or B delete)
Table 1
A new placeholder message is become to 103 and No. 104 message, which uses min_seq=
103, max_seq=104 sequence numbers identify, this is just called filling-up hole, and client takes the data with hole and is known that this load
Seq ranges among normal messages are strictly no data, just no longer go whether server requests authentication has missing information.
Or it is another example:
If 100 be a normal message, then 100 this normal messages are expressed as member (100,100), if 97,
98,99 3 normal message are all deleted, then can be merged into member (97,99).
Placeholder merging module 14 further includes:
First acquisition unit:Maximum sequence number for obtaining described at least two continuous placeholders;
To at least two continuous placeholder message using the maximum sequence number in at least two continuous placeholder message, i.e.,
For the max_seq for obtaining at least two continuous placeholder message.
Second acquisition unit:Minmal sequence number for obtaining described at least two continuous placeholders;
Minmal sequence number in at least two continuous placeholder message as obtains at least two continuous placeholders and disappears
Min_seq in breath.
Recomposition unit:For forming a placeholder according to the maximum sequence number and the minmal sequence number.
At least two continuous placeholders are merged into a new placeholder, then need this new placeholder most
Small and maximum sequence number is then used to get the sequence number of the minimum and maximum of new placeholder in S241 and S242
The minimum and maximum set of serial numbers is at a new placeholder.103 and 104 are such as merged into a new placeholder message, then
It is member (103,104) that the new placeholder message, which uses min_seq=103, max_seq=104 sequence numbers mark,.
Message issues module 15:For according to the message chain issuing message.
In specific implementation process, server there will be the message chain of placeholder to request issuing message user issue
Message.
In specific implementation process of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client
It finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity will not be again
Secondary leakage detection is filled a vacancy;The number for issuing hole can be greatly reduced based on the scheme for merging continuous loophole, reduce bandwidth occupancy.
Embodiment five:
A kind of computer readable storage medium provided in an embodiment of the present invention stores on the computer readable storage medium
There is computer program, the message issuing method described in any one technical solution is realized when which is executed by processor.Wherein, institute
It includes but not limited to any kind of disk (including floppy disk, hard disk, CD, CD-ROM and magneto-optic to state computer readable storage medium
Disk), ROM (Read-Only Memory, read-only memory), RAM (Random AcceSS Memory, immediately memory),
EPROM (EraSable Programmable Read-Only Memory, Erarable Programmable Read only Memory), EEPROM
(Electrically EraSableProgrammableRead-Only Memory, Electrically Erasable Programmable Read-Only Memory) is dodged
It deposits, magnetic card or light card.It is, storage device includes the shape can read by equipment (for example, computer, mobile phone)
Any medium of formula storage or transmission message can be read-only memory, disk or CD etc..
Referring to Fig. 7, Fig. 7 is the server of the message issuing method of the execution instant messaging in fifth embodiment of the invention
Composed structure schematic diagram.
As shown in fig. 7, a kind of server, processor 702, memory 703, input unit 704 and display unit 705 etc.
Device.Structure devices shown in Fig. 7 do not constitute the restriction to Servers-all, can components more more or less than Fig. 7 or group
Close certain components.
Memory 703 can be used for storing application program 701 and each function module, and the operation of processor 702 is stored in storage
The application program 701 of device 703, to execute various function application and the data processing of equipment.Memory can be interior storage
Device or external memory, or including both built-in storage and external memory.Built-in storage may include read-only memory (ROM),
Programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), flash memory or
Random access memory.External memory may include hard disk, floppy disk, ZIP disks, USB flash disk, tape etc..Memory packet disclosed in this invention
Include but be not limited to the memory of these types.Memory disclosed in this invention is only used as example rather than as restriction.
Input unit 704 is used to receive the input of signal, and receives keyword input by user.Input unit 704 can
Including touch panel and other input equipments.Touch panel collects user on it or neighbouring touch operation (for example is used
Family uses the operations of any suitable object or attachment on touch panel or near touch panel such as finger, stylus), and root
According to the corresponding attachment device of preset driven by program;Other input equipments can include but is not limited to physical keyboard, function
It is one or more in key (such as broadcasting control button, switch key etc.), trace ball, mouse, operating lever etc..Display unit
705 can be used for showing information input by user or be supplied to the information of user and the various menus of terminal device.Display unit
705 can be used the forms such as liquid crystal display, Organic Light Emitting Diode.Processor 702 is the control centre of terminal device, using each
The various pieces of kind interface and connection whole equipment, by running or executing the software program being stored in memory 702
And/or module, and the data being stored in memory are called, perform various functions and handle data.
As one embodiment, the computer equipment includes:One or more processors 702, memory 703, one
Or multiple application programs 701, wherein one or more of application programs 701 are stored in memory 703 and are configured as
It is executed by one or more of processors 702, one or more of programs 701 are configured to carry out in above-described embodiment
Message issuing method.
Server provided in an embodiment of the present invention can realize the embodiment of the message chain delivery method of above-mentioned offer, specifically
Function realizes the explanation that please be considered and examined in embodiment of the method, and details are not described herein.
In specific implementation process of the present invention, all operations are completed in memory, and it is very fast to execute speed;Client
It finds that placeholder is the data that may recognize that there are filling-up hole in receiving issuing message, just believes that issuing message authenticity will not be again
Secondary leakage detection is filled a vacancy;The number for issuing hole can be greatly reduced based on the scheme for merging continuous loophole, reduce bandwidth occupancy.
It should be understood that although each step in the flow chart of attached drawing is shown successively according to the instruction of arrow,
These steps are not that the inevitable sequence indicated according to arrow executes successively.Unless expressly stating otherwise herein, these steps
Execution there is no stringent sequences to limit, can execute in the other order.Moreover, at least one in the flow chart of attached drawing
Part steps may include that either these sub-steps of multiple stages or stage are not necessarily in synchronization to multiple sub-steps
Completion is executed, but can be executed at different times, execution sequence is also not necessarily to be carried out successively, but can be with other
Either the sub-step of other steps or at least part in stage execute step in turn or alternately.
The above is only some embodiments of the present invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered
It is considered as protection scope of the present invention.
Claims (10)
1. a kind of message issuing method of instant messaging, which is characterized in that include the following steps:
The message of instant messaging is obtained, the message is saved in memory by the zset data structures based on Redis, forms chain of messages
Item;
The instruction for deleting message is received, deletion message corresponding sequence number in the message chain is obtained;
Message chain corresponding position is set as placeholder according to the sequence number;
According to the message chain issuing message.
2. message issuing method according to claim 1, which is characterized in that the composition of the message includes:Message is sent
Side, message receiver, message content types and message content;The placeholder is identified model using two nodes of min and max
It encloses.
3. message issuing method according to claim 1, which is characterized in that the zset data structures based on Redis
The message is saved in memory, forms message chain, including:
Binary message is converted the message to, and is stored in memory according to the storage organization of ordered set, described in acquisition
The corresponding element of binary message;
Corresponding binding is carried out using unique score to each element;
The sequence number of the ordered set is preserved using score, realizes the shape that the binary message is converted to message chain
Formula.
4. message issuing method according to claim 1, which is characterized in that it is described according to the sequence number the message
Chain corresponding position is set as placeholder, including:
Position corresponding with the sequence number is searched in the message chain, adds same score again at the location
Element, formed placeholder.
5. message issuing method according to claim 1 or 4, which is characterized in that the minmal sequence number of the placeholder and
Maximum sequence number is the corresponding sequence number of the placeholder.
6. message chain delivery method according to claim 1, which is characterized in that described to be issued according to the message chain
Before message, further include:
Confirming the message chain, there are at least two continuous placeholders, and described at least two continuous placeholders are merged into
One placeholder.
7. message issuing method according to claim 6, which is characterized in that described described at least two continuous occupy-places
Symbol is merged into a placeholder, including:
Obtain the maximum sequence number of described at least two continuous placeholders;
Obtain the minmal sequence number of described at least two continuous placeholders;
A placeholder is formed according to the maximum sequence number and the minmal sequence number.
8. transmitting apparatus under a kind of message of instant messaging, which is characterized in that including:
Message preserving module:Message for obtaining instant messaging, the zset data structures based on Redis preserve the message
To memory, message chain is formed;
Sequence number acquisition module:For receiving the instruction for deleting message, it is right in the message chain to obtain the deletion message
The sequence number answered;
Placeholder setup module:For message chain corresponding position to be set as placeholder according to the sequence number;
Message issues module:For according to the message chain issuing message.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is held by processor
Message issuing method as claimed in any of claims 1 to 7 in one of claims is realized when row.
10. a kind of server, which is characterized in that it includes:
One or more processors;
Memory;
One or more application program, wherein one or more of application programs are stored in the memory and are configured
To be executed by one or more of processors, one or more of programs are configured to:It executes according to claim 1 to 7
Any one of described in message issuing method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810426840.2A CN108737246B (en) | 2018-05-07 | 2018-05-07 | Message issuing method, device, storage medium and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810426840.2A CN108737246B (en) | 2018-05-07 | 2018-05-07 | Message issuing method, device, storage medium and server |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108737246A true CN108737246A (en) | 2018-11-02 |
CN108737246B CN108737246B (en) | 2021-02-02 |
Family
ID=63937008
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810426840.2A Active CN108737246B (en) | 2018-05-07 | 2018-05-07 | Message issuing method, device, storage medium and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108737246B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111327915A (en) * | 2020-02-21 | 2020-06-23 | 北京字节跳动网络技术有限公司 | Method and device for determining message arrival rate |
CN111669313A (en) * | 2020-05-29 | 2020-09-15 | 广西东信互联科技有限公司 | Method for storing and synchronizing instant communication system message |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102984676A (en) * | 2012-11-29 | 2013-03-20 | 华为终端有限公司 | Method and terminal for processing message session |
US20140067375A1 (en) * | 2012-08-31 | 2014-03-06 | Next It Corporation | Human-to-human Conversation Analysis |
US20160057093A1 (en) * | 2014-08-19 | 2016-02-25 | Samsung Electronics Co., Ltd. | Method and apparatus for displaying content |
CN105490919A (en) * | 2015-11-24 | 2016-04-13 | 小米科技有限责任公司 | Message withdrawal method and device |
CN105608103A (en) * | 2015-10-16 | 2016-05-25 | 北京奇虎科技有限公司 | Transforming method and device of data storing structure |
-
2018
- 2018-05-07 CN CN201810426840.2A patent/CN108737246B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140067375A1 (en) * | 2012-08-31 | 2014-03-06 | Next It Corporation | Human-to-human Conversation Analysis |
CN102984676A (en) * | 2012-11-29 | 2013-03-20 | 华为终端有限公司 | Method and terminal for processing message session |
US20160057093A1 (en) * | 2014-08-19 | 2016-02-25 | Samsung Electronics Co., Ltd. | Method and apparatus for displaying content |
CN105608103A (en) * | 2015-10-16 | 2016-05-25 | 北京奇虎科技有限公司 | Transforming method and device of data storing structure |
CN105490919A (en) * | 2015-11-24 | 2016-04-13 | 小米科技有限责任公司 | Message withdrawal method and device |
Non-Patent Citations (1)
Title |
---|
梁智斌: "一种基于版本库的SCM系统的设计与实现", 《中国优秀硕士学位论文全文数据库》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111327915A (en) * | 2020-02-21 | 2020-06-23 | 北京字节跳动网络技术有限公司 | Method and device for determining message arrival rate |
CN111669313A (en) * | 2020-05-29 | 2020-09-15 | 广西东信互联科技有限公司 | Method for storing and synchronizing instant communication system message |
Also Published As
Publication number | Publication date |
---|---|
CN108737246B (en) | 2021-02-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11947610B2 (en) | Bulletin board data mapping and presentation | |
US6549957B1 (en) | Apparatus for preventing automatic generation of a chain reaction of messages if a prior extracted message is similar to current processed message | |
US7640263B2 (en) | Queued system event notification and maintenance | |
US20080033905A1 (en) | System and Method for the Capture and Archival of Electronic Communications | |
US20120131474A1 (en) | Switching of Emails in a Conversation Thread | |
US7584264B2 (en) | Data storage and retrieval systems and related methods of storing and retrieving data | |
CN103190123B (en) | For the method and apparatus distributing the message of issue | |
CN104079696A (en) | Contact name card generation method and device | |
CN108353018B (en) | Method, device and system for sending message | |
CN102915306B (en) | A kind of searching method and system | |
EP2461279A1 (en) | Processing of associated messages from plural social network services | |
CN105049336A (en) | Method and system for processing instant communication messages, server and client | |
CN108737246A (en) | Message issuing method, device, storage medium and server | |
CN1650586A (en) | Method and system for pushing e-mail to multiple wireless communication devices | |
CN102611641B (en) | Gather the method and system that instant messaging record carries out gathering | |
CN101163032A (en) | Method of managing alarm inquiry | |
CN108206776A (en) | A kind of querying method and device of group history message | |
CN108228432A (en) | A kind of distributed link tracking, analysis method and server, global scheduler | |
CN103279465A (en) | Method and device for controlling communication historical data | |
US11115351B2 (en) | Managing email content in an activity stream | |
CN106656735A (en) | Expression image sending method and device | |
CN102707897A (en) | Method, client and system for triggering contact object through path in instant communication | |
CN114817272A (en) | Message processing method and device, electronic equipment and storage medium | |
CN105099872A (en) | Email handling method, device and system | |
CN107181863A (en) | A kind of SMS classified and method for cleaning and its device and computer-readable recording medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |