-
Notifications
You must be signed in to change notification settings - Fork 7
Client setup
Let's step ahead and setup up the client! (Please consider reading the server setup instructions first, in case you landed here by accident!)
And again take a look at the raw base for the setup:
HydraClient client = new Client.Builder("localhost", 8888, new SampleProtocol())
.workerThreads(4)
.option(StandardSocketOptions.TCP_NODELAY, true)
.build();The builder-pattern (method-chaining) was again used for the client, but now it returns an instance of the class HydraClient. The constructor again takes three obligatory parameters. The part where the third parameter the protocol is elaborated: the protocol
As you might notice the client doesn't have boss threads, just worker threads. The standard amount of worker threads is set to two. Also there is no option to set child options for the connection, as those are handled by the server. For more information take a look at the Client class. In this class are all the configurations explained using Javadocs.
Step three doesn't differ from the Server setup, as the syntax is exactly the same.
This setup is much shorter than the server setup, as most information was already provided in the server setup instructions. Next instruction is about Sessions. You might want to check out the other methods the HydraClient class has to offer.
- Home
- Example usage of Hydra: Building a simple chat application
- Advanced example usage of Hydra: Building a small key-value store
- Example usage of Hydra's custom class serialization