CN107948051B - A kind of real-time messages method for pushing and system based on Socket technologies - Google Patents

A kind of real-time messages method for pushing and system based on Socket technologies Download PDF

Info

Publication number
CN107948051B
CN107948051B CN201711122779.4A CN201711122779A CN107948051B CN 107948051 B CN107948051 B CN 107948051B CN 201711122779 A CN201711122779 A CN 201711122779A CN 107948051 B CN107948051 B CN 107948051B
Authority
CN
China
Prior art keywords
data
module
pushing
user
comment information
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.)
Active
Application number
CN201711122779.4A
Other languages
Chinese (zh)
Other versions
CN107948051A (en
Inventor
丁玲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zhixing Rui Jing Technology Co Ltd
Original Assignee
Beijing Zhixing Rui Jing Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Zhixing Rui Jing Technology Co Ltd filed Critical Beijing Zhixing Rui Jing Technology Co Ltd
Priority to CN201711122779.4A priority Critical patent/CN107948051B/en
Publication of CN107948051A publication Critical patent/CN107948051A/en
Application granted granted Critical
Publication of CN107948051B publication Critical patent/CN107948051B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/02Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
    • H04L63/0227Filtering policies
    • H04L63/0245Filtering by information in the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present invention provides a kind of real-time messages method for pushing and system based on Socket technologies, and system includes:Data write. module, data security module, data distribution module, data-pushing module, agent transmitting module and room user management module.Data-pushing module, for reading legal comment information from corresponding buffer queue B, judge that each of room of data-pushing module self-management accesses user and enters whether time in room reads time of legal comment information earlier than data-pushing module from corresponding buffer queue B again, if earlier than the legal comment information is just pushed to access user by the data-pushing module.It has the following advantages:In conventional web, the comment information that some user delivers efficiently can quickly be presented to other current accesseds user, so as to make online friend carry out efficient interaction in conventional web, increase usage rate of the user, and then improve site volume.

Description

A kind of real-time messages method for pushing and system based on Socket technologies
Technical field
The invention belongs to Internet technical fields, and in particular to a kind of real-time messages method for pushing based on Socket technologies And system.
Background technology
Internet is to advance by leaps and bounds in development instantly, and people are higher and higher to the degree of dependence of network.Present website Quantity it is hundreds of millions of, how to allow online friend's stay long enough in website, i.e.,:Usage rate of the user is improved, online friend is made More pages are read, are the important things that each site owner must take into consideration.
Currently, online friend when reading oneself interested article, may deliver the comment of oneself, and other users are such as Fruit can view the comment content immediately, and then reply to increase the interaction between user, it will be able to allow online friend to stop well It stays in this website.But traditional webpage all operates on http protocol, can not support the business real well It is existing.
Instantly net cast website is popular, the application of above-mentioned scene can be viewed in such website, i.e.,:Hair disappears Cease barrage.Such website is that the ExternalInterface technologies based on Flash are realized.Flash technology is more than past 10 In year, critically important effect has been played;But with the release of Html5 technologies, the shortcomings that Flash technology, has just shown out. It is advantageous that Flash technology is all not so good as Html5 either functionally or in performance, or in the costs such as exploitation O&M. Therefore, it is extremely urgent to develop a real-time messages push based on Html5 technology overall background.
Invention content
In view of the defects existing in the prior art, the present invention provides a kind of real-time messages method for pushing based on Socket technologies And system, it can effectively solve the above problems.
The technical solution adopted by the present invention is as follows:
The present invention provides a kind of real-time messages method for pushing based on Socket technologies, includes the following steps:
Step 1, the total access number of website active user is obtained in real time, according to the total access number of the active user, adjustment The quantity of data-pushing module, it is assumed that the configuration quantity of data-pushing module is N number of, is denoted as respectively:1st data-pushing module, 2nd data-pushing module ... Nth data pushing module;Wherein, N is natural number;
Step 2, each data-pushing module configures a corresponding data distribution module and a buffer queue B, i.e.,: For arbitrary i-th data-pushing module, the i-th data distribution module and the i-th buffer queue B are configured;Wherein, i=1, 2...N;Therefore, it is configured with N number of data distribution module and N number of buffer queue B altogether;
Step 3, current each access user is assigned to each by agent transmitting module based on presetting allocation rule In the room of data-pushing module management, and each current accessed user is made to establish Socket long connections with website service end;
Step 4, the comment information that Data write. module real-time collecting user is submitted by the Form lists in WEB page, And the comment information is transferred to data security module;
Step 5, the data security module carries out safety filtering to the comment information, if obtaining legal comment letter Then specified data library is written in the legal comment information by breath, and successfully logical to Data write. module transmission write-in Know message;
Step 6, it after the Data write. module receives the successful notification message of write-in, legal is commented what step 5 obtained It is written in buffer queue A by information;
Step 7, N number of data distribution module polls read the legal comment information that buffer queue A is newly written, for each the The legal comment information read is written after the buffer queue A reads legal comment information for i data distribution modules Into corresponding i-th buffer queue B;Then, the i-th data-pushing module reads legal comment from corresponding i-th buffer queue B By information, then each of room for judging the i-th data-pushing module management access user enter room time whether earlier than I-th data-pushing module reads the time of legal comment information from corresponding i-th buffer queue B, if earlier than described The legal comment information is just pushed to access user by i data-pushings module;Otherwise, the i-th data-pushing module is not The legal comment information can be pushed to access user.
Preferably, in step 1, the quantity of data-pushing module is adjusted, specifically, always accessing number according to the active user Amount, increases or decreases the quantity of data-pushing module, specifically includes:
Step 1.1, a data pushing module is increased or decreased if necessary, then changes and join in data-pushing configuration file Number, increases or decreases a data-pushing port;
Step 1.2, restart website;
Step 1.3, the data-pushing configuration file is read, create or deletes data-pushing module, thus increases and adds deduct Minority is according to pushing module.
Preferably, in step 3, agent transmitting module is based on presetting allocation rule, by current each access user It is assigned in the room of each data-pushing module management, specially:
Step 3.1, agent transmitting module accesses source according to user, obtains and accesses User IP information;
Step 3.2, agent transmitting module will access user and be assigned to corresponding data-pushing module tubes according to hash algorithm In the room of reason, and access user is made to establish Socket long connections with website service end;
Step 3.3, if step 3.2 executes failure, user will be accessed and be assigned to response time shortest data-pushing In the room of module management.
Preferably, in step 3, further include:
Room user management module, for moving the user of low liveness in the room of data-pushing module management Go out, and then ensures in room that new access user can rapidly enter data-pushing module management;It specifically includes:
1) room user management module reads the room configuration file and real-time condition in the room of data-pushing module management;
2) whether carrying number in room user management module reading room, which is higher than in configuration file, is appraised and decided carrying number;If It is no, without processing;If so, to the user in room according to first in first out and minimum speech mechanism, by a certain proportion of use Family is removed;Wherein, specific ratio value is specified in room configuration file.
Preferably, in step 5, the data security module carries out safety filtering to the comment information, specially:
Security filtering index is arranged in the data security module;The data security module is according to the security filtering index Data filtering processing is carried out to the comment information, including:SQL filtration treatments, filtering sensitive words processing and advertisement filter processing, If obtaining legal comment information, the legal comment information is returned;If not obtaining legal comment information, institute's commentary By information less than the security level formulated, to submitting the access user of the comment information to carry out prohibiting locking processing of making peace.
Preferably, in step 7, the i-th data-pushing module reads legal comment letter from corresponding i-th buffer queue B Breath, specially:
The data lifetime of i-th buffer queue B is T;The i-th data-pushing module reads the i-th buffer queue B's Caching interval time is read less than data lifetime T.
The present invention also provides a kind of real-time messages supplying systems based on Socket technologies, including:
Data write. module, for the comment information that real-time collecting user is submitted by the Form lists in WEB page, and The comment information is transferred to data security module;
Data security module, the comment information for the Data write. module to be written carry out safety filtering, such as Fruit obtains legal comment information, then is sent to the Data write. module and successful notification message is written;By Data write. module Legal comment information is written in buffer queue A;
Data distribution module is N number of, and each data distribution module polls read the legal comment that buffer queue A is newly written The legal comment information read is written in corresponding buffer queue B by information;Wherein, the quantity of buffer queue B is N number of, One buffer queue B uniquely corresponds to a data distribution module;
Data-pushing module is N number of, and a data pushing module uniquely corresponds to a buffer queue B, is used for from corresponding Legal comment information is read in buffer queue B, then each of room for judging data-pushing module self-management is accessed and used Family enter room time whether read from corresponding buffer queue B earlier than data-pushing module legal comment information when Between, if earlier than the legal comment information is just pushed to access user by the data-pushing module;
Agent transmitting module, for based on presetting allocation rule, current each access user being assigned to each In the room of data-pushing module management, and each current accessed user is made to establish Socket long connections with website service end.
Preferably, further include:
Room user management module, for moving the user of low liveness in the room of data-pushing module management Go out, and then ensures in room that new access user can rapidly enter data-pushing module management.
A kind of real-time messages method for pushing and system based on Socket technologies provided by the invention have the following advantages:
In conventional web, the comment information that some user delivers efficiently can quickly be presented to other current accesseds User increases usage rate of the user so as to make online friend carry out efficient interaction in conventional web, and then improves website and visit The amount of asking.
Description of the drawings
Fig. 1 is a kind of integrated stand composition of the real-time messages supplying system based on Socket technologies provided by the invention;
Fig. 2 is the flow chart of Data write. module provided by the invention;
Fig. 3 is the flow chart of data security module provided by the invention;
Fig. 4 is the flow chart of data distribution module provided by the invention;
Fig. 5 is the flow chart of data-pushing module provided by the invention;
Fig. 6 is the flow chart of agent transmitting module provided by the invention;
Fig. 7 is the flow chart of room user management module provided by the invention.
Specific implementation mode
In order to make the technical problems, technical solutions and beneficial effects solved by the present invention be more clearly understood, below in conjunction with Accompanying drawings and embodiments, the present invention will be described in further detail.It should be appreciated that specific embodiment described herein only to It explains the present invention, is not intended to limit the present invention.
A kind of real-time messages method for pushing and system based on Socket technologies provided by the invention, can allow online friend passing Efficient interaction is carried out on system webpage, increases usage rate of the user and is combined using Node.js to improve site volume WebSocket technologies in Html5 realize the function.
Real-time messages method for pushing and system based on Socket technologies include mainly Data write. module, data safety Module, data distribution module, data-pushing module, agent transmitting module, room user management module totally six modules.Data are write Enter module to need to be used together in conjunction with data security module, the content of Data write. module output is as the defeated of data distribution module Enter information, the data of the data distribution module distribution input information as data-pushing module again, data-pushing module be responsible for by Data-pushing gives different users, realizes the effect of instant messaging.And agent transmitting module is responsible for assigning the user to difference The room that is subordinate to of data-pushing module, and room user management module is the overall technology in order to ensure that high viscosity user is online Frame is referring to attached drawing 1.
Real-time messages method for pushing based on Socket technologies, includes the following steps:
Step 1, the total access number of website active user is obtained in real time, according to the total access number of the active user, adjustment The quantity of data-pushing module, it is assumed that the configuration quantity of data-pushing module is N number of, is denoted as respectively:1st data-pushing module, 2nd data-pushing module ... Nth data pushing module;Wherein, N is natural number;
In this step, the quantity of data-pushing module is adjusted, specifically, according to the total access number of the active user, is increased Add deduct a small number of quantity according to pushing module, specifically includes:
Step 1.1, a data pushing module is increased or decreased if necessary, then changes and join in data-pushing configuration file Number, increases or decreases a data-pushing port;
Step 1.2, restart website;
Step 1.3, the data-pushing configuration file is read, create or deletes data-pushing module, thus increases and adds deduct Minority is according to pushing module.
Step 2, each data-pushing module configures a corresponding data distribution module and a buffer queue B, i.e.,: For arbitrary i-th data-pushing module, the i-th data distribution module and the i-th buffer queue B are configured;Wherein, i=1, 2...N;Therefore, it is configured with N number of data distribution module and N number of buffer queue B altogether;
Step 3, current each access user is assigned to each by agent transmitting module based on presetting allocation rule In the room of data-pushing module management, and each current accessed user is made to establish Socket long connections with website service end;
In this step, current each access user is assigned to by agent transmitting module based on presetting allocation rule In the room of each data-pushing module management, specially:
Step 3.1, agent transmitting module accesses source according to user, obtains and accesses User IP information;
Step 3.2, agent transmitting module will access user and be assigned to corresponding data-pushing module tubes according to hash algorithm In the room of reason, and access user is made to establish Socket long connections with website service end;
Step 3.3, if step 3.2 executes failure, user will be accessed and be assigned to response time shortest data-pushing In the room of module management.
In step 3, further include:
Room user management module, for moving the user of low liveness in the room of data-pushing module management Go out, and then ensures in room that new access user can rapidly enter data-pushing module management;It specifically includes:
1) room user management module reads the room configuration file and real-time condition in the room of data-pushing module management;
2) whether carrying number in room user management module reading room, which is higher than in configuration file, is appraised and decided carrying number;If It is no, without processing;If so, to the user in room according to first in first out and minimum speech mechanism, by a certain proportion of use Family is removed;Wherein, specific ratio value is specified in room configuration file.
Step 4, the comment information that Data write. module real-time collecting user is submitted by the Form lists in WEB page, And the comment information is transferred to data security module;
Step 5, the data security module carries out safety filtering to the comment information, if obtaining legal comment letter Then specified data library is written in the legal comment information by breath, and successfully logical to Data write. module transmission write-in Know message;
In step 5, the data security module carries out safety filtering to the comment information, specially:
Security filtering index is arranged in the data security module;The data security module is according to the security filtering index Data filtering processing is carried out to the comment information, including:SQL filtration treatments, filtering sensitive words processing and advertisement filter processing, If obtaining legal comment information, the legal comment information is returned;If not obtaining legal comment information, institute's commentary By information less than the security level formulated, to submitting the access user of the comment information to carry out prohibiting locking processing of making peace.
Step 6, it after the Data write. module receives the successful notification message of write-in, legal is commented what step 5 obtained It is written in buffer queue A by information;
Step 7, N number of data distribution module polls read the legal comment information that buffer queue A is newly written, for each the The legal comment information read is written after the buffer queue A reads legal comment information for i data distribution modules Into corresponding i-th buffer queue B;Then, the i-th data-pushing module reads legal comment from corresponding i-th buffer queue B By information, then each of room for judging the i-th data-pushing module management access user enter room time whether earlier than I-th data-pushing module reads the time of legal comment information from corresponding i-th buffer queue B, if earlier than described The legal comment information is just pushed to access user by i data-pushings module;Otherwise, the i-th data-pushing module is not The legal comment information can be pushed to access user.
In step 7, the i-th data-pushing module reads legal comment information from corresponding i-th buffer queue B, specifically For:
The data lifetime of i-th buffer queue B is T;The i-th data-pushing module reads the i-th buffer queue B's Caching interval time is read less than data lifetime T.
The present invention also provides a kind of real-time messages supplying systems based on Socket technologies, include mainly that mould is written in data Block, data security module, data distribution module, data-pushing module, agent transmitting module, room user management module totally six Module.Each module is discussed in detail respectively below:
(1) Data write. module
Data write. module, for the comment information that real-time collecting user is submitted by the Form lists in WEB page, and The comment information is transferred to data security module;After pending data security module carries out safety filtering processing to data, then will Legal comment information is written in buffer queue A;
Data write. module is essential module, and the flow of specific implementation is as shown in Figure 2:
1) comment information input by user is collected by the Form lists in WEB page;
2) necessary safety filtering (being handled by data security module) is carried out to the comment information of input;
3) filtered legal comment information write-in specified data library;
4) after being written successfully in above-mentioned 3, legal comment information is written in buffer queue A;Otherwise it is not written into;
5) user socket is established with website service end by agent transmitting module to connect.
(2) data security module
Data security module is used to carry out safety filtering, such as mistake to the comment information that the Data write. module is written Filter junk data, malicious code data etc..If obtaining legal comment information, it is written to Data write. module transmission The notification message of work(;Legal comment information is written in buffer queue A by Data write. module.
Data security module is essential module, and the thinking of specific implementation is with reference to figure 3:
1) pending comment information and security filtering index are read;
2) according to security filtering index to comment information filtration treatment, such as filtering insult character, SQL injection code Deng;
3) according to the security level of formulation, while to submitting the user of such comment information to carry out the processing such as taboo speech, locking;
4) the legal comment information in request end is returned to.
(3) data distribution module
Data distribution module is N number of, and N is random natural number, can be 1, or any amount.Each data Distribution module reads the legal comment information that buffer queue A is newly written for poll, and the legal comment information read is written Into corresponding buffer queue B;Wherein, the quantity of buffer queue B is N number of, and a buffer queue B uniquely divide by a corresponding data Send out module.
Data distribution module is essential module, and the thinking of specific implementation is with reference to figure 4:
1) data distribution module can have N number of, and particular number is adjusted according to the size of user volume, and each module undertakes User volume is advisable with being no more than 3000;
2) data distribution module polls read buffer queue A;
3) data read are written in buffer queue B by data distribution module, and buffer queue B may have N number of, number Amount is consistent with data distribution number of modules;
4) data lifetime in buffer queue B is usually no more than 300 seconds, and data-pushing module reads caching interval time It is necessarily less than the value.
(4) data-pushing module
Data-pushing module is N number of, is consistent with B number of above-mentioned buffer queue, a data pushing module is uniquely right A buffer queue B is answered, for reading legal comment information from corresponding buffer queue B, then judges data-pushing module Each of room of self-management access user enter room time whether earlier than data-pushing module from corresponding caching The time of legal comment information is read in queue B, if earlier than the data-pushing module is just by the legal comment information It is pushed to access user;
Data-pushing module is essential module, and the thinking of specific implementation is with reference to figure 5:
1) data-pushing module can have N number of, and particular number is adjusted according to the size of user volume, each data-pushing Module undertakes user volume to be advisable with being no more than 3000;
2) each data-pushing module polls read corresponding buffer queue B;
3) data-pushing of the buffer queue B read is given the user being each responsible for, these users by data-pushing module It is that long connection (being based on websocket protocol) is kept by socket with Website server.
(5) agent transmitting module
Agent transmitting module, for based on presetting allocation rule, current each access user being assigned to each In the room of data-pushing module management, and each current accessed user is made to establish Socket long connections with website service end.
Agent transmitting module is essential module, and specific implementation thinking is with reference to figure 6:
1) source is accessed according to user, agent transmitting module obtains User IP relevant information;
2) agent transmitting module calculates user according to HASH algorithms and is attached with X data pushing module;
If 3) connection failure in above-mentioned steps 2, the Response to selection time, shortest data-pushing module was attached;
4) user establishes Socket with server-side and connect.
(6) room user management module
Room user management module, for moving the user of low liveness in the room of data-pushing module management Go out, and then ensures in room that new access user can rapidly enter data-pushing module management.
Room user management module is optional module, but suggests using the module, the thinking reference chart of specific implementation 7:
1) configuration file and real-time condition in corresponding room, are read;
2), room user management module judges room carrying number whether less than carrying number is appraised and decided in configuration file, such as Fruit is less than, without processing;
3) after, being more than, then to the user in the room according to first in first out (FIFO) and minimum speech (LRU) both machines System removes a certain proportion of user (ratio is specified in configuration file).
Real-time messages supplying system provided by the invention based on Socket technologies, the core of the system are pushed away in data Module, such design is sent to be very suitable for increasing or decreasing come correspondingly dilatation or contraction according to user volume in the future.Data Each host process is all independently operated in pushing module, is not necessarily to communication from each other.
The invention will be further described by taking the comment of articles page real time push as an example below.
Corresponding scripted code is added in Website page, which can be carried when user to access pages to allow Rise agreement (supporting websocket);
When user A accesses the Website page, and have submitted comment information;
Server-side receives comment information, and the comment information is sent to data security module first;
Data security module carries out the comment information specified cleaning according to the needs of business, uses in the method Sql is filtered and filtering sensitive words this 2 functions are if detect at this 2 points can also carry out the operations such as taboo speech, locking to user;
Safe data are obtained after filtering can just be written into database, can be straight if not having any data after filtering Return is connect, reminds user that input is illegal;
After being written successfully, then write the data in buffer queue A;
Data in buffer queue A can be read again, is written in multiple buffer queue B, this ensures that often A data pushing module reads identical data;
Data-pushing module reads respective buffer queue B, the use being then sent to the information read in being connected thereto Family;
So far, other users that the comment information that user A is sent will be browsed the website view.
A kind of real-time messages method for pushing and system based on Socket technologies provided by the invention have the following advantages:
In conventional web, the comment information that some user delivers efficiently can quickly be presented to other current accesseds User increases usage rate of the user so as to make online friend carry out efficient interaction in conventional web, and then improves website and visit The amount of asking.
The above is only a preferred embodiment 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 Depending on protection scope of the present invention.

Claims (8)

1. a kind of real-time messages method for pushing based on Socket technologies, which is characterized in that include the following steps:
Step 1, the total access number of website active user is obtained in real time, according to the total access number of the active user, adjusts data The quantity of pushing module, it is assumed that the configuration quantity of data-pushing module is N number of, is denoted as respectively:1st data-pushing module, the 2nd number The Nth data pushing module according to pushing module ...;Wherein, N is natural number;
Step 2, each data-pushing module configures a corresponding data distribution module and a buffer queue B, i.e.,:For Arbitrary i-th data-pushing module configures the i-th data distribution module and the i-th buffer queue B;Wherein, i=1,2...N;Cause This, is configured with N number of data distribution module and N number of buffer queue B altogether;
Step 3, current each access user is assigned to each data by agent transmitting module based on presetting allocation rule In the room of pushing module management, and each current accessed user is made to establish Socket long connections with website service end;
Step 4, the comment information that Data write. module real-time collecting user is submitted by the Form lists in WEB page, and will The comment information is transferred to data security module;
Step 5, the data security module carries out safety filtering to the comment information, if obtaining legal comment information, By the legal comment information write-in specified data library, and sends write-in to the Data write. module and successfully notify to disappear Breath;
Step 6, after the Data write. module receives the successful notification message of write-in, the legal comment that step 5 is obtained is believed Breath is written in buffer queue A;
Step 7, N number of data distribution module polls read the legal comment information that buffer queue A is newly written, for each i-th number According to distribution module, after the buffer queue A reads legal comment information, the legal comment information read is written to pair In the i-th buffer queue B answered;Then, the i-th data-pushing module reads legal comment letter from corresponding i-th buffer queue B It ceases, then each of room for judging the i-th data-pushing module management accesses user and whether enters the time in room earlier than the i-th number The time of legal comment information is read from corresponding i-th buffer queue B according to pushing module, if earlier than i-th data The legal comment information is just pushed to access user by pushing module;Otherwise, the i-th data-pushing module will not be by institute It states legal comment information and is pushed to access user.
2. a kind of real-time messages method for pushing based on Socket technologies according to claim 1, which is characterized in that step In 1, the quantity of adjustment data-pushing module increases or decreases data and pushes away specifically, according to the total access number of the active user The quantity for sending module, specifically includes:
Step 1.1, a data pushing module is increased or decreased if necessary, then changes parameter in data-pushing configuration file, Increase or decrease a data-pushing port;
Step 1.2, restart website;
Step 1.3, the data-pushing configuration file is read, creates or deletes data-pushing module, thus increase or decrease number According to pushing module.
3. a kind of real-time messages method for pushing based on Socket technologies according to claim 1, which is characterized in that step In 3, agent transmitting module is assigned to each data-pushing mould based on presetting allocation rule, by current each access user In the room of block management, specially:
Step 3.1, agent transmitting module accesses source according to user, obtains and accesses User IP information;
Step 3.2, agent transmitting module will access user and be assigned to corresponding data-pushing module management according to hash algorithm In room, and access user is made to establish Socket long connections with website service end;
Step 3.3, if step 3.2 executes failure, user will be accessed and be assigned to response time shortest data-pushing module In the room of management.
4. a kind of real-time messages method for pushing based on Socket technologies according to claim 1, which is characterized in that step In 3, further include:
Room user management module, for the user of low liveness in the room of data-pushing module management to be removed, into And ensure in the room that new access user can rapidly enter data-pushing module management;It specifically includes:
1) room user management module reads the room configuration file and real-time condition in the room of data-pushing module management;
2) whether carrying number in room user management module reading room, which is higher than in configuration file, is appraised and decided carrying number;If not, Without processing;If so, to the user in room according to first in first out and minimum speech mechanism, by a certain proportion of user into Row removes;Wherein, specific ratio value is specified in room configuration file.
5. a kind of real-time messages method for pushing based on Socket technologies according to claim 1, which is characterized in that step In 5, the data security module carries out safety filtering to the comment information, specially:
Security filtering index is arranged in the data security module;The data security module is according to the security filtering index to institute It states comment information and carries out data filtering processing, including:SQL filtration treatments, filtering sensitive words processing and advertisement filter processing, if Legal comment information is obtained, then returns to the legal comment information;If not obtaining legal comment information, the comment letter Breath is less than the security level formulated, to submitting the access user of the comment information to carry out prohibiting locking processing of making peace.
6. a kind of real-time messages method for pushing based on Socket technologies according to claim 1, which is characterized in that step In 7, the i-th data-pushing module reads legal comment information from corresponding i-th buffer queue B, specially:
The data lifetime of i-th buffer queue B is T;The i-th data-pushing module reads the reading of the i-th buffer queue B Interval time is cached less than data lifetime T.
7. a kind of real-time messages supplying system based on Socket technologies, which is characterized in that including:
Data write. module, for the comment information that real-time collecting user is submitted by Form lists in WEB page, and by institute It states comment information and is transferred to data security module;
Data security module, the comment information for the Data write. module to be written carry out safety filtering, if To legal comment information, is then sent to the Data write. module and successful notification message is written;It will be closed by Data write. module Method comment information is written in buffer queue A;
Data distribution module is N number of, and each data distribution module polls read the legal comment information that buffer queue A is newly written, The legal comment information read is written in corresponding buffer queue B;Wherein, the quantity of buffer queue B is N number of, one Buffer queue B uniquely corresponds to a data distribution module;
Data-pushing module is N number of;Wherein, the quantity of data-pushing module obtains in the following ways:Website is obtained in real time to work as The preceding total access number of user adjusts the quantity of data-pushing module according to the total access number of the active user;
One data pushing module uniquely corresponds to a buffer queue B, for reading legal comment from corresponding buffer queue B By information, then each of room for judging data-pushing module self-management access user enter room time whether earlier than Data-pushing module reads the time of legal comment information from corresponding buffer queue B, if earlier than the data-pushing The legal comment information is just pushed to access user by module;
Agent transmitting module, for based on presetting allocation rule, current each access user to be assigned to each data In the room of pushing module management, and each current accessed user is made to establish Socket long connections with website service end.
8. a kind of real-time messages supplying system based on Socket technologies according to claim 7, which is characterized in that also wrap It includes:
Room user management module, for the user of low liveness in the room of data-pushing module management to be removed, into And ensure in the room that new access user can rapidly enter data-pushing module management.
CN201711122779.4A 2017-11-14 2017-11-14 A kind of real-time messages method for pushing and system based on Socket technologies Active CN107948051B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711122779.4A CN107948051B (en) 2017-11-14 2017-11-14 A kind of real-time messages method for pushing and system based on Socket technologies

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711122779.4A CN107948051B (en) 2017-11-14 2017-11-14 A kind of real-time messages method for pushing and system based on Socket technologies

Publications (2)

Publication Number Publication Date
CN107948051A CN107948051A (en) 2018-04-20
CN107948051B true CN107948051B (en) 2018-10-12

Family

ID=61931986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711122779.4A Active CN107948051B (en) 2017-11-14 2017-11-14 A kind of real-time messages method for pushing and system based on Socket technologies

Country Status (1)

Country Link
CN (1) CN107948051B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111282263A (en) * 2020-03-03 2020-06-16 北京奇艺世纪科技有限公司 Event message processing method and device, electronic equipment and readable storage medium
CN112351293B (en) * 2020-10-26 2021-09-21 北京达佳互联信息技术有限公司 Method, device and medium for detecting state signaling loss

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100359474C (en) * 2005-06-24 2008-01-02 中国人民解放军国防科学技术大学 Method for constructing Web server based on soft flow construction and server thereof
CN101097527B (en) * 2006-06-27 2011-11-30 中国银联股份有限公司 Flowpath scheduling method and system of application progress
CN101217554B (en) * 2008-01-14 2010-07-14 苏州阔地网络科技有限公司 An instant communication method realized on website

Also Published As

Publication number Publication date
CN107948051A (en) 2018-04-20

Similar Documents

Publication Publication Date Title
CN101415010B (en) WEB browsing apparatus and operation method
Krishnamurthy et al. A few chirps about twitter
CN102609460B (en) Method and system for microblog data acquisition
CN103838814B (en) Method for dynamically displaying contacts diagram relationship
CN103078881B (en) Internet resources Download Info share control system and method
WO2018121331A1 (en) Attack request determination method, apparatus and server
CN101287166B (en) Short message publishing system and method for auxiliary system of electronic meeting
CN104219069B (en) access frequency control method, device and control system
CN109391661B (en) Block chain networking method and system for terminal of Internet of things
CN102281309B (en) The dissemination method of the network information and the delivery system of the network information and client
CN107948051B (en) A kind of real-time messages method for pushing and system based on Socket technologies
WO2012171404A1 (en) Method, device and system for sharing microblog message
CN101588344A (en) System and method for controlling same account login in network system
CN103618733A (en) Data filtering system and method applied to mobile internet
CN103379019A (en) Microblog message pushing method, device and system
CN104994139A (en) System capable of quickly responding to high-concurrency network request
CN108600088A (en) Data processing method and device
CN103312586B (en) A kind of method of instant messaging, system and server
CN201985891U (en) System for preventing harassment of strangers in social network
CN108765683A (en) A kind of ballot system based on block chain technology
WO2014079320A1 (en) Method and system for processing message in social network
CN102801640B (en) A kind of method and apparatus of message examination & verification
CN102521379A (en) Internet information collection method and internet information collection device based on active push technology
CN103312822A (en) Push-based SNS protocol optimization method
WO2017067195A1 (en) Location-based comment information synchronous broadcast method, apparatus and system

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
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A real-time message push method and system based on socket technology

Effective date of registration: 20210923

Granted publication date: 20181012

Pledgee: Zhongguancun Beijing technology financing Company limited by guarantee

Pledgor: BEIJING ZHIXING RUIJING TECHNOLOGY Co.,Ltd.

Registration number: Y2021990000867

PE01 Entry into force of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20230118

Granted publication date: 20181012

Pledgee: Zhongguancun Beijing technology financing Company limited by guarantee

Pledgor: BEIJING ZHIXING RUIJING TECHNOLOGY Co.,Ltd.

Registration number: Y2021990000867

PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A real-time message push method and system based on Socket technology

Effective date of registration: 20230406

Granted publication date: 20181012

Pledgee: Zhongguancun Beijing technology financing Company limited by guarantee

Pledgor: BEIJING ZHIXING RUIJING TECHNOLOGY Co.,Ltd.

Registration number: Y2023990000202

PC01 Cancellation of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right

Granted publication date: 20181012

Pledgee: Zhongguancun Beijing technology financing Company limited by guarantee

Pledgor: BEIJING ZHIXING RUIJING TECHNOLOGY Co.,Ltd.

Registration number: Y2023990000202