How To use the server-side API
You can use Rethync SDK in standalone mode and to implement plugin for Rethync Server software.
The sequence of calls in code when using Rethync SDK (server side) is
- (in standalone mode) Create an instance of the transport class
- in .NET and VCL assign event handlers to events of transport instance. In C++, Java and PHP you need to implement IBaseServerTransportEvents interface and pass the reference to the interface to BaseServerTransport.setEvents method.
- (in standalone mode) In OnNewConnection event handler create an instance of ServerEngine class and assign it to Connection.Engine property. A separate instance of the engine is used for each connection, but you can reuse engine objects after connection is closed.
- (in standalone mode) In OnNewConnection event handler you need to create a request handler (see next step).
- In all languages the request handler can be created by implementing IServerRequestHandler interface and assigning a reference to BaseServerEngine.RequestHandler property (or setRequestHandler method depending on the language used). In .NET and VCL you alternatively can create an instance of EventServerRequestHandler class, implement its event handlers and assign this instance to BaseServerEngine.RequestHandler property.
- (in standalone mode) The transport needs to be tuned up and activated.
- In HTTP server transport you call its ProcessRequest method to handle each request (see description of the HTTP server class for details).
- MsgConnect server transport fires OnNewConnection event when it receives client requests.
- All server synchronization logic is implemented in EventServerRequestHandler event handlers (.NET, VCL) or IServerRequestHandler class. It is expected that the client calls synchronization methods in particular order, but your server-side logic should be ready for any unexpected call and return an appropriate error (depending on context) if the method is not expected.
- (in standalone mode) Deactivate the transport when the server is shut down.
Got questions or comments about this topic? Tell us about them.