send result (failure) for SEND even if there's an exception

This commit is contained in:
Eric House 2012-02-01 18:42:30 -08:00
parent ab32480cd5
commit b3fdcecaf4

View file

@ -387,6 +387,7 @@ public class BTService extends Service {
private void sendMsg( BTQueueElem elem ) private void sendMsg( BTQueueElem elem )
{ {
boolean success = false;
try { try {
BluetoothDevice dev = m_adapter.getRemoteDevice( elem.m_addr ); BluetoothDevice dev = m_adapter.getRemoteDevice( elem.m_addr );
BluetoothSocket socket = BluetoothSocket socket =
@ -406,17 +407,18 @@ public class BTService extends Service {
DataInputStream inStream = DataInputStream inStream =
new DataInputStream( socket.getInputStream() ); new DataInputStream( socket.getInputStream() );
boolean success = success =
BTCmd.MESG_ACCPT == BTCmd.values()[inStream.readByte()]; BTCmd.MESG_ACCPT == BTCmd.values()[inStream.readByte()];
socket.close(); socket.close();
BTEvent evt = success ? BTEvent.MESSAGE_ACCEPTED
: BTEvent.MESSAGE_REFUSED;
sendResult( evt, elem.m_gameID, 0, elem.m_recipient );
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.logf( "sendInvites: ioe: %s", ioe.toString() ); DbgUtils.logf( "sendInvites: ioe: %s", ioe.toString() );
success = false;
} }
BTEvent evt = success ? BTEvent.MESSAGE_ACCEPTED
: BTEvent.MESSAGE_REFUSED;
sendResult( evt, elem.m_gameID, 0, elem.m_recipient );
} }
private void addAddr( BluetoothSocket socket ) private void addAddr( BluetoothSocket socket )