HI all:

Delving deeper into mina, and things are starting to make sense - really
more of a comment on some newbie is using this stuff. Any advice or comments
welcomed - there may be better ways to do what I'm trying to do.

My use case is to set up an HTTPS connection, and push data both ways once
the connection has been established from the client. On Trustin's advice
(thx) I started with the example.httpserver.codec example, and now have
bi-directional messages flying back and forth - this is really very cool. 

The server is modified example code, and the client app is Java sockets
stuff (to mimic what we will have to write in C on the hardware device). The
client just starts a thread to suck up HTTP messages and spew them to the
console, and can send HTTP requests up to the server.

To make things work, I did have to make one change to the example code - 

1. In ServerHandler.messageReceived, had to change the line:

    session.write(response).addListener(IoFutureListener.CLOSE);

to

   session.write(response);

to keep the session open - this seems reasonable to me.

The active IoSession objects are kept around on the server - to send a
message from the server to the client, the appropriate IoSession is looked
up from the map, an HttpResponse message is created, and
session.write(httpResponse) is called. Wicked.

It all is lookin' groovy - I can send messages either way (ie. not limited
to request/response).

Next up is to layer the SSL on top - I'm assuming that I can add a SSL
filter to the chain, and then re-cruft the client code to use SSL over the
socket.

Really cool - the HttpServerProtocolCodecFactory was what turned the
lightbulb on here.

Kudos - this is great - thanks.

parki...


-- 
View this message in context: 
http://www.nabble.com/Comments-and-use-of-htttpserver.codec-example-code-tf4807038s16868.html#a13753108
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to