Hi,

MINA makes developing NIO based apps a lot easier. ATM, documentation is
a problem for new users. It also complicates things that there are two
versions, one stable (0.8.x) and one unstable (0.9.x). Most of the docs
in the wiki is for the stable version I think. Some of the things you
are referring to (Service and ProtocolHandler) have been removed in MINA
0.9.x. I would suggest you go with the unstable version though since IMO
the API has been simplified yet you have more features to play with.
It's not really that unstable either, 0.9.x is already being used in
production systems.

So what do you need to know to get started? Well, IoSession is sort of
the MINA equivalent of an NIO SocketChannel. It is mainly used to write
data and manage the state of the connection (like closing it or
enable/disable reading/writing). IoAcceptors accept new connections and
IoConnectors are used to connect to other hosts. Your server will be
using an instance of one of the IoAcceptor implementations while your
clients will be using the corresponding IoConnector implementation. ATM
there are IoAcceptor and IoConnector implementations for UDP
(DatagramAcceptor/Connector), TCP (SocketAcceptor/Connector) and in-VM
(VmPipeAcceptor/Connector) communication.

MINA's programming model is asnychronous. MINA will call you when
something happens on a socket. All you need to do to start receiving
events from MINA is to implement the IoHandler interface and register an
instance of this implementation with an IoAcceptor or IoConnector.

MINA's filter concept is a really powerful thing. A chain of filters is
associated with each new session. When an IoAcceptor or IoConnector
receives a message for a session from the underlying network it will
pass the message to the first filter of the session. The filter can take
some action depending on the message contents. If desired it can pass
the (possibly modified) message on to the next filter in the chain. The
last filter in the chain will pass messages to your IoHandler
implementation. If you have worked with servlets this concept is very
similar to the servlet filter concept.

MINA includes some very useful filters like the SSLFilter which
decrypts/encrypts all messages passing through it. The ThreadPoolFilter
is another useful filter.

To get started I think you should have a look at the examples. The echo
app is a good example of a minimal MINA based server:
http://svn.apache.org/viewcvs.cgi/directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/
I think you could use it as a starting point for your server. Instead of
echoing the data (the position) from client1 you would send the data to
client2 and vice versa.

I hope this has made things a little clearer. Don't hesitate to ask any
futher questions on this list.

Regards,
Niklas

John Stevens wrote:
> Thanks for the reply Trustin.
> 
> I meant no offence with regards to the documentation. I can appreciate
> that those with a strong background in network programming can grasp
> MINA quicker than one like me with the info provided on the website.
> Just to narrow the question down I'm writing a simple 2D game which
> currently has 2 clients and 1 server. It's that basic scenario where the
> player on client 1 moves his/her position and then data is sent to the
> server which then sends the data to client 2. Client 2 posotions are
> also sent to client 1 via the server.
> 
> The thing I would love to know and really start off with is how I can
> use MINA to send the movement data to the server and vice-versa. I've
> looked at the examples and get a little confused with the Service class
> and what it is used for as well as IOHandlers, ProtocolHandlers, etc. It
> seems approaching networking programming is conceptually different using
> MINA than using standard Java IO/NIO even though it may be using NIO
> beneath it.
> 
> It's probably my confusion and lack of understanding of the MINA
> framework and philosophy that has resulted in this. Hence, the question
> about more docs to clarify MINA with fully documented examples.
> 
> A basic start of approaching my problem is what I desperately need and
> any info is valuable. Thanks again for replying Trustin.
> 
> 
> John
> 
> _________________________________________________________________
> Customise your home page with RSS feeds at MSN Ireland! http://ie.msn.com/
> 
> 


-- 
Med vänlig hälsning

Niklas Therning
Software Architect

[EMAIL PROTECTED]
Mobil: +46 739 75 05 73

Trillian - Software Design at its best
www.trillian.se

Reply via email to