mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
add protocol-identifier byte. For now just assert it matches.
This commit is contained in:
parent
ac2ac47aed
commit
898d9c339a
1 changed files with 5 additions and 0 deletions
|
@ -60,6 +60,8 @@ public class BTService extends Service {
|
|||
public void eventOccurred( BTEvent event, Object ... args );
|
||||
}
|
||||
|
||||
private static final int BT_PROTO = 0;
|
||||
|
||||
private static final int PING = 0;
|
||||
private static final int SCAN = 1;
|
||||
private static final int INVITE = 2;
|
||||
|
@ -305,6 +307,8 @@ public class BTService extends Service {
|
|||
DbgUtils.logf( "run: accept() returned" );
|
||||
inStream = new DataInputStream( socket.getInputStream() );
|
||||
|
||||
byte proto = inStream.readByte();
|
||||
Assert.assertTrue( proto == BT_PROTO );
|
||||
byte msg = inStream.readByte();
|
||||
BTCmd cmd = BTCmd.values()[msg];
|
||||
switch( cmd ) {
|
||||
|
@ -721,6 +725,7 @@ public class BTService extends Service {
|
|||
try {
|
||||
socket.connect();
|
||||
dos = new DataOutputStream( socket.getOutputStream() );
|
||||
dos.writeByte( BT_PROTO );
|
||||
dos.writeByte( cmd.ordinal() );
|
||||
DbgUtils.logf( "connect successful" );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
|
|
Loading…
Reference in a new issue