CN111343236A - Method, device and communication system for communication between server and client - Google Patents

Method, device and communication system for communication between server and client Download PDF

Info

Publication number
CN111343236A
CN111343236A CN202010082374.8A CN202010082374A CN111343236A CN 111343236 A CN111343236 A CN 111343236A CN 202010082374 A CN202010082374 A CN 202010082374A CN 111343236 A CN111343236 A CN 111343236A
Authority
CN
China
Prior art keywords
communication
client
server
module
preset
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.)
Pending
Application number
CN202010082374.8A
Other languages
Chinese (zh)
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.)
Guangzhou Jisheng Network Technology Co ltd
Original Assignee
Guangzhou Jisheng Network 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 Guangzhou Jisheng Network Technology Co ltd filed Critical Guangzhou Jisheng Network Technology Co ltd
Priority to CN202010082374.8A priority Critical patent/CN111343236A/en
Publication of CN111343236A publication Critical patent/CN111343236A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • 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/51Discovery or management thereof, e.g. service location protocol [SLP] or web services

Abstract

The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, a communication system, a computer device, and a storage medium for a server to communicate with a client. The method comprises the following steps: the server side responds to the message sending instruction, and obtains message content and client identity information corresponding to the message sending instruction; determining the current configuration information of a communication protocol configuration item in a preset configuration file; determining a communication module identifier corresponding to the current configuration information; determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information. The embodiment of the invention can reduce the code amount required to be written by developers.

Description

Method, device and communication system for communication between server and client
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, a communication system, a computer device, and a storage medium for a server to communicate with a client.
Background
In the field of games, for example, for scenes with high requirements for real-time performance and interactivity, the game program may use a TCP (transmission control Protocol) Protocol, for scenes with high requirements for real-time performance and accessibility, and the game program may use a UDP (user datagram Protocol) Protocol.
In actual development, programs using different communication protocols may use the same service or service module, for example, a game a is a role playing game based on a TCP protocol, a ranking list module needs to be developed, a game B is a shooting game based on a UDP protocol, a ranking list module also needs to be developed, the ranking list modules used by the two games respectively may be very similar or even identical in code logic, but because the communication protocols used by the two games are different, a communication framework usually only uses a certain fixed communication protocol at present, developers need to develop a ranking list module for the game a alone and also develop a ranking list module for the game B alone. This increases the development burden on the developer.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a method, a device, a communication system, computer equipment and a storage medium for communication between a server and a client.
The present invention provides a method for a server to communicate with a client according to a first aspect, and in one embodiment, the method includes:
responding to a message sending instruction, and acquiring message content and client identity information corresponding to the message sending instruction;
determining the current configuration information of a communication protocol configuration item in a preset configuration file;
determining a communication module identifier corresponding to the current configuration information;
and determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
In one embodiment, before the step of obtaining, by the server, the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction, the method includes:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the service code, and determining a preset annotation identifier contained in the service code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In an embodiment, the step of updating, by the server, the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier includes:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
The present invention provides according to a second aspect a communication system, which in one embodiment comprises: the system comprises a first computing device and a plurality of second computing devices, wherein the first computing device comprises one or more server modules and a plurality of communication modules, communication protocols configured among the communication modules are different, each second computing device comprises a client module, and the communication protocols configured among the client modules of the second computing devices are different;
any one server module in the first computing device, configured to respond to a message sending instruction, obtain message content and client identity information corresponding to the message sending instruction, determine current configuration information of a communication protocol configuration item in a preset configuration file, determine a communication module identifier corresponding to the current configuration information, determine a target communication module corresponding to the communication module identifier among the plurality of communication modules, and send the message content and the client identity information to the target communication module;
any communication module in the first computing device is used for determining a target second computing device corresponding to the client identity information from the plurality of second computing devices when receiving the message content and the client identity information sent by any server module; the message content is sent to the target second computing device.
In one embodiment, before the step of obtaining, by any server module, the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction, the method includes:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the service code, and determining a preset annotation identifier contained in the service code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In an embodiment, the step of updating, by any server module, the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier includes:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
In an embodiment, the client module on the second computing device is configured to, when receiving a message upload instruction, obtain a message upload content and target server identity information corresponding to the message upload instruction, determine target communication module identity information corresponding to the target server identity information, and send the message upload content and the target server identity information to a communication module corresponding to the target communication module identity information in the first computing device, so that the communication module sends the message upload content to the server module corresponding to the target server identity information.
The present invention provides, according to a third aspect, an apparatus for a server to communicate with a client, in one embodiment, the apparatus includes:
the instruction corresponding information acquisition module is used for responding to the message sending instruction and acquiring the message content and the client identity information corresponding to the message sending instruction;
the configuration information determining module is used for determining the current configuration information of the communication protocol configuration item in the preset configuration file;
a module identification determining module for determining the communication module identification corresponding to the current configuration information;
and the information sending module is used for determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending the message content and the client identity information to the target communication module so that the target communication module sends the message content to a target client corresponding to the client identity information.
The present invention provides according to a fourth aspect a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of an embodiment of any of the methods described above when executing the computer program.
The present invention provides according to a fifth aspect a computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of an embodiment of any of the methods described above.
In the embodiment of the invention, a server side responds to a message sending instruction, and obtains message content and client identity information corresponding to the message sending instruction; then determining the current configuration information of the communication protocol configuration items in the preset configuration file; determining a communication module identifier corresponding to the current configuration information; the method comprises the steps of determining a target communication module corresponding to a communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending message content and client identity information to the target communication module so that the target communication module sends the message content to a target client corresponding to the client identity information, wherein a plurality of communication modules configured with different communication protocols are preset in a communication layer in the embodiment, and a server can select which communication module is to be called to communicate with the client according to the configuration, namely, the embodiment can enable the clients adopting different communication protocols to share one server, so that services or service modules with similar logic among programs adopting different communication protocols can be extracted to be used as a single application, and simultaneously, the service is provided for each program, and developers do not need to repeatedly develop the programs with different communication protocols and similar logic or even share the same server Consistent business modules or services reduce the amount of code that needs to be written.
Drawings
Fig. 1 is a diagram illustrating a communication architecture between a server and a client according to the prior art;
FIG. 2 is a diagram of an application environment of a method for a server to communicate with a client in one embodiment;
FIG. 3 is a diagram illustrating the communication architecture between a server and a client in one embodiment;
FIG. 4 is a diagram illustrating the communication architecture between a server and a client in another embodiment;
FIG. 5 is a flowchart illustrating a method for a server to communicate with a client in one embodiment;
FIG. 6 is a block diagram of an embodiment of a device for a server to communicate with a client;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Fig. 1 is a diagram of a communication architecture between a server and a client at present, where the server and the client both configure the same communication protocol, and can be seen as two major service modules (including multiple services or services) and a communication module inside the server, and communication between the service modules and the client needs to be implemented through the communication module. It should be noted that, an existing communication framework usually has a communication protocol, and a service module developed based on the communication framework is coupled with a communication module, so if a server and a client of a program need to communicate using other communication protocols, the communication framework and the like on the bottom layer must be replaced, which is very troublesome to implement and has a large workload.
In addition, even if programs using different communication protocols need to use the same service or service, developers need to develop the same service or service separately, and there is no way to extract the same service or service to make a common independent service or independent service.
Therefore, an embodiment of the present invention provides a method for a server to communicate with a client.
The method is suitable for the application environment a (shown as 'a' in fig. 2) and the application environment b (shown as 'b' in fig. 2) which adopt a client-server (client-server) architecture as shown in fig. 2.
In the application environment a, a server 10 (hereinafter, referred to as a server) has a server program installed therein and has a server role, and a server 21, a server 22, and a server 2N (hereinafter, referred to as a client server) each have a client program installed therein and have client roles. The server 10 can communicate with each client service, and it should be noted that the communication protocols used for the communication between each client server and the server 10 are different, for example, the client server 21 communicates with the server 10 using a TCP Protocol, the client server 22 communicates with the server 10 using a UDP Protocol, and the client server 2N communicates with the server 10 using an HTTP (hypertext transfer Protocol) Protocol.
The architecture of the application scenario a in terms of communication is shown in fig. 3, a server program on the server 10 includes a service module and a plurality of communication modules, and each communication module is preconfigured with different communication protocols, for example, a TCP communication module, an udp communication module, an http communication module, a websocket (a protocol for performing full-duplex communication on a single TCP connection) communication module, and the like. The service implementation and the communication implementation of the server program are mutually isolated, namely the service module and each communication module are decoupled. When a service module in a server program needs to communicate with a corresponding client program, a communication module which has the same communication protocol as the communication protocol configured by the client program is called, and communication with the client program can be realized through the communication module, so that one server program can communicate with the client programs configured with different communication protocols through a communication layer of which the communication module can be switched. Therefore, services or service modules with similar logics among the programs adopting different communication protocols can be extracted to be used as a single application, the single application is used as a server (namely server) and each program is used as a client (namely client), and the single application can simultaneously provide the same service for each program. For example, if the game program a is a role playing game based on the TCP protocol, it is necessary to develop a ranking list module, the game program B is a shooting game based on the UDP protocol, it is also necessary to develop a ranking list module logically identical to the ranking list module of the game program a, and then the developer only needs to develop a ranking list module, configure the ranking list module as a server, set the game program a and the game program B as clients, respectively, when the ranking list module needs to communicate with the game program A (which refers to the server where the game program is located), the ranking list module sends the relevant communication information to the game program A through the tcp communication module, and similarly, when the ranking list module needs to communicate with the B game program (here, the server where the game program is located), the ranking list module sends the relevant communication information to the B game program through the udp communication module.
Specifically, when the server program needs to change the communication protocol, the user (for example, a developer, an operation and maintenance person, or other person having authority to add the annotation identifier) only needs to add the annotation identifier corresponding to the communication protocol to be used in the program code, such as the class code and/or the method code in the class code, before the program code is started, the configuration file may be dynamically modified, so that the service module of the server program calls the communication module corresponding to the annotation identifier to communicate. It can be understood that if the client program to be communicated does not need to be re-developed, the communication protocol adopted by the client needs to be changed into the communication protocol subsequently adopted by the server. For example, if a certain role-playing game program using a TCP protocol is to be changed to a UDP protocol, the communication protocol used by the client program is changed to the UDP protocol, but the operation of changing the protocol of the server program only requires a developer (certainly, an operation and maintenance person, etc.) to add @ UDP server in front of the relevant code in the program code, so that the program can switch the communication module serving the service module from the TCP communication module to the UDP communication module when being started, and the role-playing game program can communicate with the client terminal using the UDP protocol.
It is understood that a communication module is used to support a communication protocol, and in different scenarios, the type and number of communication protocols to be used by the server program are different, and thus the number of communication modules included in the program and the respective supported communication protocols are also different. How many communication protocols are used by the server program, which communication protocols are supported are determined by developers according to specific scenes, which is not limited by the embodiment of the invention.
Further, as shown in fig. 4, in the communication aspect of the application scenario a, a plurality of server programs are installed on the server 10, functions implemented by service modules included in the server programs are different from each other, however, the service modules of the server programs share one communication layer, for example, a game a using the TCP protocol and a game B using the UDP protocol share one ranking list module, a game C using the TCP protocol and a game D using the UDP protocol share one chat room module, and the ranking list module and the chat room module may be installed on the same server and share one communication layer. The communication layer comprises a plurality of communication modules with different communication protocols, and the service module in each server program can call the corresponding communication module when needing to communicate with the corresponding client program, so developers do not need to repeatedly develop service modules or services with similar or even consistent logics, and the code amount needing to be compiled is reduced. It can be understood that the communication protocol configured by the communication module called by the service module of any server program is the same as the communication protocol configured by the client program to be communicated by the service module. In addition, when any server program needs to switch the currently used communication protocol, the switching operation is also the operation of adding annotation identification corresponding to the communication protocol to be used later by the user in the program code related to communication, such as the class code and/or the method code in the class code.
It should be noted that "first", "second", and "N" in the first client, the second client, the first server, the second server, and the like shown in fig. 3 and fig. 4 refer to not the several clients and the several servers, but are used to identify the category of the communication protocol configured by the client. For example, if the "first" corresponding communication protocol is a TCP protocol, the "first server" refers to a server program configured with the TCP communication protocol, and the "first client" refers to a client program configured with the TCP communication protocol.
Further, in the application environment b, the server 10 can communicate with a plurality of intelligent terminals (i.e. 31, 32, 3N shown in the figure) installed with different client programs. The intelligent terminal includes, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, desktop computers, and the like. In the application environment b, the details of the communication process between the server 10 and the intelligent terminal are the same as those of the description of the application environment a, and are not described herein again.
Fig. 5 shows a method for a server to communicate with a client according to an embodiment of the present invention, which can be applied to the server 10 (hereinafter referred to as a server) in fig. 2.
The method comprises the following steps:
s110: and responding to the message sending instruction, and acquiring the message content and the client identity information corresponding to the message sending instruction.
In this embodiment, the message sending instruction refers to an instruction that the server needs to send a message to the client through the communication module after receiving the message. The message sending instruction may be an instruction which is issued by a user (such as a developer, an operation and maintenance worker, a tester, and the like) to the server and enables the server to send a message to the client, and since the server needs to feed back a request of the client after receiving the request, the message sending instruction may also be a request from the client or an instruction which is generated by the server itself and used for sending a message to the client. That is to say, when any server program on a server needs to send a message to a client corresponding to the server program (i.e., a client server or a terminal only on which the client program corresponding to the server program is installed), message content and client identity information corresponding to a received message sending instruction are determined first, where the message content refers to information that the server needs to send to the client, and the client identity information includes a client identifier, a client ip address, and port information corresponding to the client program on the client server or the intelligent terminal where the client program is located.
S120: and determining the current configuration information of the communication protocol configuration items in the preset configuration file.
In this embodiment, the preset configuration file includes information required by the server during operation, and the communication protocol configuration item in the configuration file is used to specify a communication protocol to be used by the server.
The communication protocol supported and used by the communication layer is corresponding to a unique communication protocol identifier, and the user configures the configuration information corresponding to the communication protocol configuration item in the configuration file into the communication protocol identifier of the communication protocol to be used by the user when the user wants to use what communication protocol to communicate. The communication layer has a plurality of communication modules which are configured with different communication protocols in advance, each communication module is pre-allocated with a communication module identifier for distinguishing different communication modules, and a mapping relation is pre-established by each communication protocol identifier and the corresponding communication module identifier, so that the corresponding communication module identifier can be determined by the communication protocol identifier configured on the communication protocol configuration item.
S130: and determining the communication module identification corresponding to the current configuration information.
In this embodiment, after the server determines the current configuration information, the server can determine the corresponding communication module identifier.
S140: determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
In this embodiment, the server may be connected to a plurality of preset communication modules, the communication protocols configured on the plurality of communication modules are different, after the server determines the communication module identifier, only the received message content and the client identity information need to be sent to the communication module corresponding to the communication module identifier, that is, the target communication module, and the target communication module may automatically perform subsequent operations, that is, determine the client corresponding to the client identity information, then establish a communication connection with the client, and send the message content to the client through the communication connection.
In this embodiment, the communication layer is preset with a plurality of communication modules configured with different communication protocols, and the server can select to call a corresponding communication module to communicate with the client according to the configuration, that is, the clients adopting different communication protocols can share one server, so that services or service modules with similar logic between programs adopting different communication protocols can be extracted to serve as a single application, and simultaneously, services are provided for each program. For developers, business modules or services with similar or even consistent logic do not need to be repeatedly developed, and the code amount needing to be written is reduced.
In one embodiment, before the step of obtaining, by the server, the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction, the method includes:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the service code, and determining a preset annotation identifier contained in the service code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In this embodiment, when a developer writes a program in advance, the developer abstracts the communication mode or the communication function used by the program in the core module in the software project of the program in advance to obtain a plurality of communication modules, and needs to write a set of API (Application programming interface) for calling the communication modules, which is not related to the specific communication implementation. When a developer writes relevant codes of a business module subsequently, a statement comment (the statement comment refers to an annotation identifier, such as @ TcpServer and @ UdpServer) corresponding to the API can be added to the business method to declare the business method, it needs to be explained that the business method is completely unrelated to specific communication implementation, but the relevant codes of the business method can call the corresponding communication module through the API when running, so that the effect of decoupling the business code implementation and the communication implementation can be achieved.
Specifically, after the server receives a program start instruction, before or during the loading of the program code into the java virtual machine by the class loader, a relevant code of the business module, that is, a business code, is determined, and then the business code is scanned, for example, a code scanning tool may be used to scan whether a preset annotation identifier is added to the class code or the method code in the code, where the preset annotation identifier is an annotation identifier used for specifying a communication protocol to be used by the server, such as @ TcpServer, @ Tcp, and the like. And if the corresponding preset annotation identification is scanned, updating the corresponding configuration information according to the preset annotation identification.
Specifically, the step of updating, by the server, the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier includes:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
Each communication protocol identifier has its corresponding annotation identifier, for example, the annotation identifier corresponding to the TCP protocol is @ TcpServer, and the annotation identifier corresponding to the UDP protocol is @ UDP server. And determining the corresponding communication protocol identifier through the preset annotation identifier, and replacing the configuration information corresponding to the communication protocol configuration item in the preset configuration file with the communication protocol identifier corresponding to the preset annotation identifier.
In one embodiment, the present invention provides a device for a server to communicate with a client, as shown in fig. 6, including the following modules:
an instruction corresponding information obtaining module 110, configured to respond to a message sending instruction, and obtain message content and client identity information corresponding to the message sending instruction;
a configuration information determining module 120, configured to determine current configuration information of a communication protocol configuration item in a preset configuration file;
a module identifier determining module 130, configured to determine a communication module identifier corresponding to the current configuration information;
the information sending module 140 is configured to determine a target communication module corresponding to the communication module identifier among a plurality of preset communication modules configured with different communication protocols, and send the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
In one embodiment, before the device for the server to communicate with the client performs the function corresponding to the instruction corresponding information acquiring module, the device further performs the functions corresponding to the following modules:
the service code determining module is used for responding to a program starting instruction and determining a service code corresponding to the program starting instruction;
the annotation identification determining module is used for scanning the business code and determining a preset annotation identification contained in the business code;
and the configuration information updating module is used for updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation identifier.
In one embodiment, the configuration information update module includes:
the protocol identifier determining submodule is used for determining a communication protocol identifier corresponding to the preset annotation identifier;
and the configuration information updating submodule is used for updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
For specific limitations of the device for the server to communicate with the client, reference may be made to the above limitations of the method for the server to communicate with the client, which are not described herein again. All or part of each module in the device for the communication between the server and the client can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, the present invention also provides a communication system, comprising: the system comprises a first computing device and a plurality of second computing devices, wherein the first computing device comprises one or more server modules and a plurality of communication modules, communication protocols configured among the communication modules are different, each second computing device comprises a client module, and the communication protocols configured among the client modules of the second computing devices are different;
any one server module in the first computing device, configured to respond to a message sending instruction, obtain message content and client identity information corresponding to the message sending instruction, determine current configuration information of a communication protocol configuration item in a preset configuration file, determine a communication module identifier corresponding to the current configuration information, determine a target communication module corresponding to the communication module identifier among the plurality of communication modules, and send the message content and the client identity information to the target communication module;
any communication module in the first computing device is used for determining a target second computing device corresponding to the client identity information from the plurality of second computing devices when receiving the message content and the client identity information sent by any server; the message content is sent to the target second computing device.
Further, the client modules in the second computing devices are configured to receive message content sent by a certain communication module, and a communication protocol configured by the certain communication module is consistent with a communication protocol configured by each client module.
In this embodiment, if the first computing device in the communication system includes one server module, the server may select to invoke the corresponding communication module to communicate with the corresponding client module according to the configuration, that is, the client modules using different communication protocols can share one server module, if the first computing device in the communication system includes a plurality of server modules, each server module may share a plurality of communication modules in one communication layer, for example, a game a using a TCP protocol and a game B using a UDP protocol share one ranking list module, a game C using the TCP protocol and a game D using a UDP protocol share one chat room module, and the ranking list module and the chat room module may be installed on the same server and share one communication layer including a plurality of communication modules. For developers, business modules or services with similar or even consistent logic do not need to be repeatedly developed, and the code amount needing to be written is reduced.
In one embodiment, before the step of obtaining, by any server module, the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction, the method includes:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the service code, and determining a preset annotation identifier contained in the service code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In an embodiment, the step of updating, by any server module, the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier includes:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
In an embodiment, the client module in each second computing device is configured to determine, after receiving a message content sent by any one of the communication modules, server identity information corresponding to the message content and communication module identity information corresponding to the any one of the communication modules, and establish a mapping relationship between the server identity information and the communication module identity information.
In an embodiment, each of the client modules on the second computing devices is configured to, when receiving a message upload instruction, obtain a message upload content and target server identity information corresponding to the message upload instruction, determine target communication module identity information corresponding to the target server identity information, and send the message upload content and the target server identity information to a communication module corresponding to the target communication module identity information in the first computing device, so that the communication module sends the message upload content to the server module corresponding to the target server identity information.
For specific limitations of the communication system, reference may be made to the above method for the server to communicate with the client, and limitations of an application environment of the method, which are not described herein again.
In one embodiment, a computer device is provided, the internal structure of which may be as shown in FIG. 7. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as configuration information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method for a server to communicate with a client.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
responding to a message sending instruction, and acquiring message content and client identity information corresponding to the message sending instruction; determining the current configuration information of a communication protocol configuration item in a preset configuration file; determining a communication module identifier corresponding to the current configuration information; and determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
In one embodiment, the processor executes the computer program to realize the following steps before the step of obtaining the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction; scanning the service code, and determining a preset annotation identifier contained in the service code; and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In one embodiment, when the processor executes the computer program to implement the step of updating the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier, the following steps are further implemented:
determining a communication protocol identifier corresponding to the preset annotation identifier; and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
responding to a message sending instruction, and acquiring message content and client identity information corresponding to the message sending instruction; determining the current configuration information of a communication protocol configuration item in a preset configuration file; determining a communication module identifier corresponding to the current configuration information; and determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
In one embodiment, the computer program is executed by a processor, and before the step of obtaining the message content and the client identity information corresponding to the message sending instruction in response to the message sending instruction, the following steps are further implemented:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction; scanning the service code, and determining a preset annotation identifier contained in the service code; and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation mark.
In one embodiment, when the computer program is executed by the processor and updates the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation identifier, the following steps are further implemented:
determining a communication protocol identifier corresponding to the preset annotation identifier; and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for a server to communicate with a client is characterized in that the method is applied to the server and comprises the following steps:
responding to a message sending instruction, and acquiring message content and client identity information corresponding to the message sending instruction;
determining the current configuration information of a communication protocol configuration item in a preset configuration file;
determining a communication module identifier corresponding to the current configuration information;
determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending the message content and the client identity information to the target communication module, so that the target communication module sends the message content to a target client corresponding to the client identity information.
2. The method according to claim 1, wherein the obtaining of the message content and the client identity information corresponding to the message sending command in response to the message sending command comprises:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the business code, and determining a preset annotation identifier contained in the business code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation identifier.
3. The method according to claim 2, wherein the updating the configuration information of the communication protocol configuration item in the preset configuration file according to the preset annotation mark comprises:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
4. A communication system, comprising: the system comprises a first computing device and a plurality of second computing devices, wherein the first computing device comprises one or more server modules and a plurality of communication modules, communication protocols configured among the communication modules are different, each second computing device comprises a client module, and the communication protocols configured among the client modules of the second computing devices are different;
any one server module in the first computing device, configured to respond to a message sending instruction, obtain message content and client identity information corresponding to the message sending instruction, determine current configuration information of a communication protocol configuration item in a preset configuration file, determine a communication module identifier corresponding to the current configuration information, determine a target communication module corresponding to the communication module identifier among the plurality of communication modules, and send the message content and the client identity information to the target communication module;
any communication module in the first computing device is used for determining a target second computing device corresponding to the client identity information from the plurality of second computing devices when receiving the message content and the client identity information sent by any server module; sending the message content to the target second computing device.
5. The communication system of claim 4,
before the step of responding to the message sending instruction and acquiring the message content and the client identity information corresponding to the message sending instruction, any one of the server modules comprises:
responding to a program starting instruction, and determining a service code corresponding to the program starting instruction;
scanning the business code, and determining a preset annotation identifier contained in the business code;
and updating the configuration information of the communication protocol configuration items in the preset configuration file according to the preset annotation identifier.
6. The communication system of claim 5,
the step of updating the configuration information of the communication protocol configuration item in the preset configuration file by any server module according to the preset annotation mark comprises the following steps:
determining a communication protocol identifier corresponding to the preset annotation identifier;
and updating the current configuration information of the communication protocol configuration item in the preset configuration file into the communication protocol identifier corresponding to the preset annotation identifier.
7. The communication system of claim 4, wherein the client module on the second computing device is configured to, when receiving a message upload instruction, obtain message upload content and target server identity information corresponding to the message upload instruction, determine target communication module identity information corresponding to the target server identity information, and send the message upload content and the target server identity information to the communication module corresponding to the target communication module identity information in the first computing device, so that the communication module sends the message upload content to the server module corresponding to the target server identity information.
8. A device for a server to communicate with a client, comprising:
the instruction corresponding information acquisition module is used for responding to a message sending instruction and acquiring message content and client identity information corresponding to the message sending instruction;
the configuration information determining module is used for determining the current configuration information of the communication protocol configuration item in the preset configuration file;
a module identifier determining module, configured to determine a communication module identifier corresponding to the current configuration information;
and the information sending module is used for determining a target communication module corresponding to the communication module identifier in a plurality of preset communication modules configured with different communication protocols, and sending the message content and the client identity information to the target communication module so that the target communication module sends the message content to a target client corresponding to the client identity information.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 3 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 3.
CN202010082374.8A 2020-02-07 2020-02-07 Method, device and communication system for communication between server and client Pending CN111343236A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010082374.8A CN111343236A (en) 2020-02-07 2020-02-07 Method, device and communication system for communication between server and client

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010082374.8A CN111343236A (en) 2020-02-07 2020-02-07 Method, device and communication system for communication between server and client

Publications (1)

Publication Number Publication Date
CN111343236A true CN111343236A (en) 2020-06-26

Family

ID=71186801

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010082374.8A Pending CN111343236A (en) 2020-02-07 2020-02-07 Method, device and communication system for communication between server and client

Country Status (1)

Country Link
CN (1) CN111343236A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901437A (en) * 2020-08-04 2020-11-06 北京一起教育信息咨询有限责任公司 Message transmission method, device and system
CN112688952A (en) * 2020-12-28 2021-04-20 京信网络系统股份有限公司 Message processing method, device, radio remote unit and medium
CN112769776A (en) * 2020-12-27 2021-05-07 百果园技术(新加坡)有限公司 Distributed service response method, system, device and storage medium
CN112769837A (en) * 2021-01-13 2021-05-07 北京洛塔信息技术有限公司 Websocket-based communication transmission method, device, equipment, system and storage medium
CN113268230A (en) * 2021-05-18 2021-08-17 深圳希施玛数据科技有限公司 Feedback information generation method, device, terminal and storage medium
CN114048303A (en) * 2022-01-11 2022-02-15 北京安博通科技股份有限公司 System and method for disposing response of man-machine cooperative combat
CN116192784A (en) * 2023-03-03 2023-05-30 广州三七极耀网络科技有限公司 Message notification method, device and equipment based on broadcast robot

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100205053A1 (en) * 2009-02-03 2010-08-12 Gary Stephen Shuster Http trigger for out-of-protocol action
CN105024971A (en) * 2014-04-18 2015-11-04 中兴通讯股份有限公司 Communication protocol conversion method and communication protocol conversion device
US20170126844A1 (en) * 2015-10-30 2017-05-04 Microsoft Technology Licensing, Llc Server architecture and protocol development
WO2017124976A1 (en) * 2016-01-22 2017-07-27 阿里巴巴集团控股有限公司 Method and device for acquiring application resource
CN107835178A (en) * 2017-11-13 2018-03-23 北京奇艺世纪科技有限公司 A kind of multi-protocols communication for service method, apparatus and electronic equipment
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100205053A1 (en) * 2009-02-03 2010-08-12 Gary Stephen Shuster Http trigger for out-of-protocol action
CN105024971A (en) * 2014-04-18 2015-11-04 中兴通讯股份有限公司 Communication protocol conversion method and communication protocol conversion device
US20170126844A1 (en) * 2015-10-30 2017-05-04 Microsoft Technology Licensing, Llc Server architecture and protocol development
WO2017124976A1 (en) * 2016-01-22 2017-07-27 阿里巴巴集团控股有限公司 Method and device for acquiring application resource
CN107835178A (en) * 2017-11-13 2018-03-23 北京奇艺世纪科技有限公司 A kind of multi-protocols communication for service method, apparatus and electronic equipment
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901437A (en) * 2020-08-04 2020-11-06 北京一起教育信息咨询有限责任公司 Message transmission method, device and system
CN111901437B (en) * 2020-08-04 2022-12-20 北京一起教育信息咨询有限责任公司 Message transmission method, device and system
CN112769776A (en) * 2020-12-27 2021-05-07 百果园技术(新加坡)有限公司 Distributed service response method, system, device and storage medium
CN112688952A (en) * 2020-12-28 2021-04-20 京信网络系统股份有限公司 Message processing method, device, radio remote unit and medium
CN112688952B (en) * 2020-12-28 2022-09-30 京信网络系统股份有限公司 Message processing method, device, radio remote unit and medium
CN112769837A (en) * 2021-01-13 2021-05-07 北京洛塔信息技术有限公司 Websocket-based communication transmission method, device, equipment, system and storage medium
CN112769837B (en) * 2021-01-13 2023-07-04 北京洛塔信息技术有限公司 Communication transmission method, device, equipment, system and storage medium based on WebSocket
CN113268230A (en) * 2021-05-18 2021-08-17 深圳希施玛数据科技有限公司 Feedback information generation method, device, terminal and storage medium
CN113268230B (en) * 2021-05-18 2023-09-08 深圳希施玛数据科技有限公司 Feedback information generation method and device, terminal and storage medium
CN114048303A (en) * 2022-01-11 2022-02-15 北京安博通科技股份有限公司 System and method for disposing response of man-machine cooperative combat
CN116192784A (en) * 2023-03-03 2023-05-30 广州三七极耀网络科技有限公司 Message notification method, device and equipment based on broadcast robot
CN116192784B (en) * 2023-03-03 2023-11-03 广州三七极耀网络科技有限公司 Message notification method, device and equipment based on broadcast robot

Similar Documents

Publication Publication Date Title
CN111343236A (en) Method, device and communication system for communication between server and client
CN110049098B (en) Distributed operation quick starting system and method for mobile phone application
CN111726399B (en) Docker container secure access method and device
CN110602169B (en) Service calling method and device, computer equipment and storage medium
CN111273963B (en) Application program configuration information generation method and device, computer equipment and medium
CN111193716A (en) Service data calling method and device, computer equipment and storage medium
CN110555041A (en) Data processing method, data processing device, computer equipment and storage medium
CN110958217B (en) Method and device for remotely controlling server, computer equipment and storage medium
JP2023523242A (en) DATA PROCESSING METHOD, DATA PROCESSING APPARATUS, COMPUTER DEVICE, AND COMPUTER PROGRAM
CN108595280B (en) Interface adaptation method and device, computer equipment and storage medium
CN111752582A (en) Software updating method and device in local area network and electronic equipment
CN108345508B (en) Interface call testing method and device
CN111966530A (en) Disaster recovery switching method and device for application system, computer equipment and storage medium
CN112911374A (en) DLNA (digital Living network alliance) -based screen projection method and system
CN110784414B (en) Data interaction method, device, electronic equipment and storage medium
CN111901395A (en) Multi-cluster switching method and device
CN109639629B (en) Data access processing method and device, computer equipment and storage medium
CN111026988A (en) Page loading method, device and system and computer equipment
CN110286956B (en) Plug-in operation method and device and electronic equipment
CN112866414B (en) Data information pushing method and device, computer equipment and storage medium
CN114556891A (en) Method, device, equipment and storage medium for determining equipment state
CN113590565B (en) Series multi-terminal data transmission method, system, equipment and medium
CN112769824B (en) Information transmission state updating method, terminal, device and storage medium
CN113268348B (en) Switching method and device of distributed lock server, computer equipment and medium
CN113986379B (en) Application starting method and device, computer equipment and storage 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200626

RJ01 Rejection of invention patent application after publication