Hi,

> 1) is the client under your control ? Ie, can you make so that the
client does not send any message until teh handshake has completed ?

Actually the client is more the server part, i open the connection,
the "client" then send a string with the supported protocol
variants like this (end by \n):

VARIANt1;VARIANT2;VARIANt3

Next is send the desired variant and get the version like this:

1.2;1.3;2.2

As the last part i send back the desired version which gets acknowledge
be the client.

That is the handshake, now the client or i can send messages, before this moment no other messages are exchanged. So yes i client is more or
less  under control.

2) In case you can't control the client, what I understand is that you
differ the decoding of the received message until the handshake is
completed. Am I right ?

Yes your are good. After the handshake a slightly modified xml messages
are exchanged. I use a ProtocolCodecFilter for that.

regards


Max


Le 3/27/14 8:31 PM, Max Larsson a écrit :

Hi,

i have a question regarding who to implement it in a nice way.

Background:

The protocol i implements has upon a connection establishment a
small handshake. Mainly to choose which version and variant of
the protocol to use.
For the handshake i implemented a StateMachine, which upon a
session create event start the handshake. Thats works fine.

Now if i use the higher level implementation i have a method
connect which tells mina to use my iohandler etc and try to build
a connection. Next i send some protocol messages. Now i have the
problem that the handshake needs some time and between connect
and sending a message the state machine hasn't yet gone through
the handshake and thus don't forward the message top the socket,
as long it isn't in the matching state.
To avoid that i do the following in the connect method:

- connect
- wait for sessionCraeted event // now the StateMachine performs the
hadnshake
- i sleep for about 2 seconds

And for that last step i have a feeling there must be a better way
to implement that?


best regards


Max Larsson





--
_____________________________________________________________________

http://facilityboss.biz
http://facebook.com/facilityboss
_____________________________________________________________________

Max Larsson
facilityboss GmbH
Rheinstrasse 75, 64295 Darmstadt / Germany
Handelsregister Darmstadt, HRB 86193
Geschäftsführer: Dipl.-Inform. Max Lars Robert Larsson

Mobil: +49 179 2184428
Email: [email protected]

Reply via email to