FastSocket learning notes ~ In addition, the composition of the client and the server, fastsocket learning notes
More nonsense
A long time ago, I wrote several articles about FastSocket, which basically belong to the method of use, but lack a Summary of the concept. In this article, I will make up for the shortcomings of the previous articles, let's talk about the core modules. Let's talk about them again!
FastSocket is composed of the Client and the Server. during development, we can reference the corresponding DLL and add the core FastSocketBase. for the client, we can convert the business object into our data packet, that is, the byte array, and then sends data packets by directing to the server. The server receives the request, obtains the data stream (byte array), and then parses the data stream, convert the data stream into an object and then perform corresponding operations.
Client core Diagram
Response [Response body]
Defines the data entity of the business environment, and the business layer assigns a value to it for display.
Protocol (Protocol package)
Processes the message and converts it to the specified core Reponse. It usually converts the object attribute to the row type of the byte array. More directly, it assigns a value to the Response object, here, the value assignment to the byte array is involved.
Client (Client message initiator)
Send the data packet with response as the data carrier to the specified server command channel, and provide the method callback function, that is, after the server completes processing, and provides a method callback.
For the server, the architecture is simpler. It consists of services, protocol packages, and commands on the server. A service can set multiple commands, and commands are constructed by data packets on the server, it is used to convert the data packets in the request to the specified object, so it is similar to the client's Response function.
Now, let's take a look at the FastSocket principle.