combining Subscriber and Publisher into one client

tvtkg2510tvtkg2510 TienOrganization: University of QueenslandProject: develop an application, namely UV Smart, which makes use of sensed environmental information to provide users with warnings on their overexposure to UV. Member

Hi everyone,
I'm working on an assignment using Icebox to develop an Ice application on Java IDE, one of the assessment that required 2 classes that both sending and receiving data. I was only given the Ice Storm demo which have Publisher and Subscriber classes, I would like to know if there is any way to combine them into one class so that I can have a two-way system? I've already tried copy the code of subscriber into the publisher but I reecognized that it wasnt the right way.
Many thanks.

Comments

  • bernardbernard Jupiter, FLBernard NormierOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff

    Hi Tien,

    With Ice, you have clients that use proxies to send requests to remote objects, and servers that host object implementations (known as servants) and listen for requests from clients.

    In IceStorm, we talk about about "publishers" and "subscribers": a publisher is an Ice client that sends requests to subscribers (via IceStorm), while a subscriber is an Ice object that receives these requests (via IceStorm).

    Your Subscriber servant class in Java derives from a generated "Disp" class, for example:
    https://github.com/zeroc-ice/ice-demos/blob/3.6/java/IceStorm/clock/Subscriber.java#L11
    (in a typical application this class would be be a standalone class, not a nested class)

    There is however no particular requirement on what a client or publisher class looks like: it just uses one or more proxies, and it does not need to derive from anything.

    You can add a proxy data member to your servant class, initialize this proxy ... and your Subscriber is now a client, possibly a Publisher if this proxy is similar to the clock proxy in the same demo: https://github.com/zeroc-ice/ice-demos/blob/3.6/java/IceStorm/clock/Publisher.java#L110.

    Cheers,
    Bernard

Sign In or Register to comment.