~vcs-imports/skycastle/trunk

« back to all changes in this revision

Viewing changes to modules/core/src/main/java/org/skycastle/protocol/ProtocolCommunicator.java

  • Committer: zzorn
  • Date: 2008-11-10 14:55:40 UTC
  • Revision ID: vcs-imports@canonical.com-20081110145540-l1hvmkbhnd0612ws
Fixed compile: removed packages of unused code, updated to use new Darkstar API, moved external library versions to the master pom.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import org.skycastle.util.ParameterChecker;
7
7
 
8
8
import java.io.Serializable;
 
9
import java.nio.ByteBuffer;
9
10
 
10
11
/**
11
12
 * Takes care of negotiating a protocol, and after that forwarding decoded messages to a listener.
124
125
     *
125
126
     * @throws ProtocolException if there was a problem when decoding this message.
126
127
     */
127
 
    public final void handleReceivedEncodedMessage( final byte[] byteMessage )
 
128
    public final void handleReceivedEncodedMessage( final ByteBuffer byteMessage )
128
129
            throws ProtocolException
129
130
    {
130
131
        final NegotiationStatus status = myProtocolNegotiator.getStatus();
185
186
    /**
186
187
     * Called when a byte array message should be sent to the other party.
187
188
     */
188
 
    protected abstract void sendEncodedMessage( final byte[] encodedMessage );
 
189
    protected abstract void sendEncodedMessage( final ByteBuffer encodedMessage );
189
190
 
190
191
    /**
191
192
     * Called if protocol negotiations failed for some reason.
213
214
    //======================================================================
214
215
    // Private Methods
215
216
 
216
 
    private void doNegotiationRound( final byte[] byteMessage )
 
217
    private void doNegotiationRound( final ByteBuffer byteMessage )
217
218
    {
218
 
        final byte[] reply = myProtocolNegotiator.handleMessage( byteMessage );
 
219
        final ByteBuffer reply = myProtocolNegotiator.handleMessage( byteMessage );
219
220
 
220
221
        if ( reply != null )
221
222
        {
242
243
    }
243
244
 
244
245
 
245
 
    private void handleMessage( final byte[] byteMessage )
 
246
    private void handleMessage( final ByteBuffer byteMessage )
246
247
            throws ProtocolException
247
248
    {
248
249
        // Decode incoming message and notify decendant implementation