-
Notifications
You must be signed in to change notification settings - Fork 0
CommunicationHandling (pull)
This is the section about how you can realize a pull-system.
The important interface to look at is: de.thorbenkuck.netcom2.network.client.Sender. This interface is instantiated by calling Sender.open().
This interface provides you with 3 functions.
- objectToServer(Object o)
- registrationToServer(Class clazz, Observer observer)
- unRegistrationToServer(Class clazz)
The first one is straight forward. You simply send something, that has to be specified at the Server-side.
Remember, you specify a Communication with
ServerStart.getCommunicationRegistration
.register(MessageObject.class)
.addLast((session, o) -> {}); The Server can, in return, answer using either
session.send(new AnswerObject());or
distributor.toSpecific(/* ... */) ;whilst the user is correctly injected into each OnReceive implementation.
As a tip, if you register Communications at the ClientStart, you can also get an "Session"-object injected. This is the Clients-Representation of the Server.
The second and third one are a bit more tricky. What do i mean with "registration"?
Well, you, as a Client, can register to a specific Class. The Observer, you specific at the method-call, is called, when a new Object arrives. At the Server-Side you can than simply say "distributor.toAllRegistered()" and they will find their way. However, you can also use an internal Cache, tho this is further detailed in the next Section, Push.
Now, basically you now know everything about pull. At the ClientSide send and at the ServerSide, answer it. Now you can get into the sweet stuff, Push.
Introduction
Advanced
Outdated
Further Reading
Versions explained
Examples