Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Writing Unsolicited Messages to a Connected Netty Client


Copy link to this message
-
Re: Writing Unsolicited Messages to a Connected Netty Client
Hi Armin,

Could you explain a little more about what you're trying to do?  It sounds
like you want a protocol in which either client or the server initiates a
remote procedure call.  The easiest way to do this is to have the client
also be a server and the server also be a client.  For example, consider
the following protocols:

protocol WeatherClient {
  double getTemperature(string postalCode);
  void registerForTemperatureUpdates(string postalCode, string clientHost,
int clientPort);
}

protocol WeatherUpdateListener {
  void onTemperatureUpdate(String postalCode, double newTemperature);
}

The client side would use WeatherClient (and
SpecificRequestor/NettyTransceiver) to request the temperature for some
postal code from the server.  The client could also register with the
server for temperature updates by passing the postal code it's interested
in as well as the hostname/IP and port of a netty server running on the
client.  The client would run its own netty server using a
WeatherUpdateListener and SpecificResponder.  When the server has a
temperature update to send back to the client, it would send a message to
the client using the WeatherUpdateListener interface.  Is this close to
what you're looking for?

-James
On Fri, Jan 20, 2012 at 6:34 AM, Armin Garcia <[EMAIL PROTECTED]>wrote:

> I am trying to figure out how a message can be sent through a Netty Server
> to a connected client.  I see the channel is stored in a group for each
> client that connects to a Netty Server:
>
> public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
> throws Exception
> {
>      e.getChannel().write(null);
>      *allChannels.add(e.getChannel());*
>      super.channelOpen(ctx, e);
> }
>
> The challenge is how to leverage this channel in order to send an
> unsolicited message to the client.  Is there an example that writes to the
> channel but not as a response to a message received?
>
> I fully expect to take the existing Netty Server and modify it.  I suspect
> the solution lies somewhere in creating a NettyDataPack then writing it to
> the channel.  I'm definitely an Avro  greenhorn, so I'm a bit unsure of how
> to wrangle my message into a NettyDataPack.
>
>            -Armin
>
>
>