Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of instant communication method, can save network traffics.
Another object of the present invention is to provide a kind of instant communicating system, can save network traffics.
Another purpose of the present invention is to provide a kind of client, can save network traffics.
A purpose more of the present invention is to provide a kind of Relay Server, can save network traffics.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of instant communication method comprises:
After the user utilizes a client X to login, said client X set up with Relay Server between long the connection;
When the user writes data at every turn, said client X set up with operations server between short the connection, and short connection that the data that write are passed through to be set up sent to said operations server; Said operations server set up with said Relay Server between short the connection, and lack to connect and send to said Relay Server what the data that write were passed through to be set up; Said Relay Server with the data that write utilize self with instant communication server between set up long the connection send to said instant communication server;
When receiving after said instant communication server returns to the data of said client X, said Relay Server utilize self with said client X between set up long the connection data of returning are sent to said client X.
A kind of instant communicating system comprises: client, Relay Server, operations server and instant communication server; Wherein, the number of said client is more than one;
Each client X, be respectively applied for when the user utilize self login after, set up with said Relay Server between grow and be connected; When the user writes data at every turn; Set up with said operations server between lack and be connected; The short connection that the data that write are passed through to be set up sends to said operations server, and through with said Relay Server between set up long the connection receive said instant communication server that said Relay Server sends and return to the data of self;
Said operations server is used for after receiving the data that write, set up with said Relay Server between short the connection, and lack to connect and send to said Relay Server what the data that write were passed through to be set up;
Said Relay Server; Be used for the data that write utilize self with said instant communication server between set up long the connection send to said instant communication server; And when receiving after said instant communication server returns to the data of said client X, utilize self with said client X between set up long the connection data of returning are sent to said client X.
A kind of client comprises: first processing unit and second processing unit;
Said first processing unit, be used for when the user utilize self login after, set up with Relay Server between long the connection;
Said second processing unit is used for when the user writes data at every turn, set up with operations server between short the connection, and short connection that the data that write are passed through to be set up sent to said operations server;
Said first processing unit is further used for, through said long the connection receiving instant communication server that said Relay Server sends and return to the data of self.
A kind of Relay Server comprises: the 3rd processing unit and is managed the unit everywhere;
Said the 3rd processing unit; Be used for through self with operations server between set up short the connection receive the data that user that said operations server sends writes, with the data that write utilize self with instant communication server between set up grow to be connected and send to said instant communication server;
Said the manages the unit everywhere, is used for when receiving after said instant communication server returns to the data of arbitrary client, utilize self with said client between set up long the connection data of returning are sent to said client.
It is thus clear that, adopt technical scheme of the present invention, client through with Relay Server between set up long the connection obtain instant communication server and return to the data of self, thereby avoided setting up one after another useless short connection, and then saved network traffics.
Embodiment
To the problem that exists in the prior art, the instant messaging scheme among the present invention after a kind of improvement of proposition can be saved network traffics.
For make technical scheme of the present invention clearer, understand, below with reference to the accompanying drawing embodiment that develops simultaneously, scheme according to the invention is done to specify further.
The flow chart of Fig. 1 instant communication method embodiment of the present invention.As shown in Figure 1, may further comprise the steps:
Step 11: after the user utilizes a client X to login, client X set up with Relay Server between long the connection.
In the present embodiment, adopt the long mode that connects simulation Socket communication of HTTP (HTTP, HyperText Transfer Protocol).
Fig. 2 for client X of the present invention set up with Relay Server between the long process sketch map that is connected.As shown in Figure 2, comprising:
Step 201: client X sends link order to Relay Server.
Said link order can be GET/abcqq.com HTTP/1.1.
Step 202: Relay Server returns welcome message to client X.
Said welcome message can be<script>Hello ();</script>
So far, connect foundation.
Step 12: when the user writes data at every turn, client X set up with operations server between short the connection, and short connection that the data that write are passed through to be set up sent to operations server; Operations server set up with Relay Server between short the connection, and short connection that the data that write are passed through to be set up sent to Relay Server.
In the present embodiment, user's read-write operation is separated, and dispose the server of difference in functionality, i.e. operations server and Relay Server accordingly.
When the user writes data at every turn, client X can set up with operations server between short the connection, through this weak point connection the data that write are sent to operations server; After operations server receives the data that write, it is simply unpacked processing, and short connection the between foundation and the Relay Server, the data after unpacking are sent to Relay Server.
Step 13: Relay Server with the data that write utilize self with instant communication server between set up long the connection send to instant communication server.
Fig. 3 for Relay Server of the present invention set up with instant communication server between the long process sketch map that is connected.As shown in Figure 3, comprising:
Step 301: Relay Server sends link order to instant communication server.
Said link order can be USR abcqq.com.
Step 302: instant communication server returns welcome message to Relay Server.
Said welcome message can be OK.
So far, connect foundation.
Relay Server can carry out package again to it after receiving the data after the unpacking that operations server sends, and promptly is encapsulated as the form that meets the instant communication server requirement, and long connection of passing through to be set up sends to instant communication server.
Follow-up, how instant communication server is treated to prior art to the data that receive.
Step 14: when receiving after instant communication server returns to the data of client X, Relay Server utilize self with client X between set up long the connection data of returning are sent to client X.
In this step, Relay Server through with client X between long connection of setting up, the data that instant communication server returned to client X send to client X.
In addition, embodiment illustrated in fig. 1 in, in order to save resource, Relay Server also can periodically travel through self with each client between all long connections of setting up; And, confirm respectively whether it is in disabled state, if not, then do not deal with to each the long Y of connection that traverses; If then send and wake instruction up, and determine whether to send successfully, if unsuccessful to the long Y of connection; Then break off the long Y of connection, thereby discharge its shared resource, if success does not then deal with.
Wherein, To each the long Y of connection that traverses; Relay Server can obtain it and enliven the time at last, if this duration that enlivens interval between time and current time at last, can confirm then that the long Y of connection is in disabled state (possible user's off-line) greater than pre-set threshold.The concrete value of said threshold value can be decided according to the actual requirements.
Based on above-mentioned introduction, the present invention provides a kind of instant communicating system simultaneously.
Fig. 4 is the composition structural representation of instant communicating system embodiment of the present invention.As shown in Figure 4, comprising: client 41, Relay Server 42, operations server 43 and instant communication server 44; Wherein, the number of client 41 is more than one, and is promptly one or more, for simplifying accompanying drawing, only expressed one among Fig. 4.
Each client X 41, be respectively applied for when the user utilize self login after, set up with Relay Server 42 between grow and be connected; When the user writes data at every turn; Set up with operations server 43 between lack and be connected; The short connection that the data that write are passed through to be set up sends to operations server 43, and through with Relay Server 42 between set up longly is connected instant communication server 44 that reception Relay Server 42 sends and returns to the data of self;
Operations server 43 is used for after receiving the data that write, set up with Relay Server 42 between short the connection, and lack to connect and send to Relay Server 42 what the data that write were passed through to be set up;
Relay Server 42; Be used for the data that write utilize self with instant communication server 44 between set up long the connection send to instant communication server 44; And when receiving after instant communication server 44 returns to the data of client X 41, utilize self with client X 41 between set up long the connection data of returning are sent to client X 41.
Above-mentioned Relay Server 42 also can be further used for; Periodically travel through self with each client 41 between all long connections of setting up; To each the long Y of connection that traverses; Confirm respectively whether it is in disabled state; If then send and wake instruction up, and determine whether to send successfully to the long Y of connection; If unsuccessful, then break off the long Y of connection.
The present invention provides a kind of client simultaneously, comprising: first processing unit and second processing unit;
Wherein, first processing unit, be used for when the user utilize self login after, set up with Relay Server between long the connection;
Second processing unit is used for when the user writes data at every turn, set up with operations server between short the connection, and short connection that the data that write are passed through to be set up sent to operations server;
Above-mentioned first processing unit is further used for, through said long the connection receiving instant communication server that Relay Server sends and return to the data of self.
The present invention provides a kind of Relay Server simultaneously, comprising: the 3rd processing unit and is managed the unit everywhere;
Wherein, The 3rd processing unit; Be used for through self with operations server between set up short the connection receive the data that user that operations server sends writes, with the data that write utilize self with instant communication server between set up grow to be connected and send to instant communication server;
The manages the unit everywhere, is used for when receiving after instant communication server returns to the data of arbitrary client, utilize self with this client between set up long the connection data of returning are sent to this client.
In addition, also can further comprise in this Relay Server:
The 5th processing unit; Be used for periodically traveling through self with each client between all long connections of setting up; To each the long Y of connection that traverses; Confirm respectively whether it is in disabled state; If then send and wake instruction up, and determine whether to send successfully to the long Y of connection; If unsuccessful, then break off the long Y of connection.
Specifically, the 5th processing unit can obtain enlivening the time at last of the long Y of connection, if this duration that enlivens interval between time and current time at last, confirms then that the long Y of connection is in disabled state greater than pre-set threshold.
The concrete workflow of said system and device embodiment repeats no more please with reference to the respective description among the method embodiment shown in Figure 1 here.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being made, is equal to replacement, improvement etc., all should be included within the scope that the present invention protects.