mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-26 07:58:52 +01:00
send ack after creating game on receipt of SMS invitation. Thought
about starting up the game so it could connect, but that'd make it impossible to change any settings, e.g. player name, on the accepting end.
This commit is contained in:
parent
019a053df0
commit
d67614cd69
3 changed files with 40 additions and 6 deletions
|
@ -1920,4 +1920,7 @@
|
|||
|
||||
<string name="confirm_clear">Are you sure you want to delete the
|
||||
checked phone number[s]?</string>
|
||||
|
||||
<string name="invite_success">Invitation accepted.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -843,16 +843,26 @@ public class BoardActivity extends XWActivity
|
|||
} );
|
||||
}
|
||||
break;
|
||||
|
||||
// This can be BT or SMS. In BT case there's a progress
|
||||
// thing going. Not in SMS case.
|
||||
case NEWGAME_FAILURE:
|
||||
DbgUtils.logf( "failed to create game" );
|
||||
case NEWGAME_SUCCESS:
|
||||
if ( 0 == --m_invitesPending ) {
|
||||
m_handler.post( new Runnable() {
|
||||
public void run() {
|
||||
final boolean success =
|
||||
MultiService.MultiEvent.NEWGAME_SUCCESS == event;
|
||||
final boolean allHere = 0 == --m_invitesPending;
|
||||
m_handler.post( new Runnable() {
|
||||
public void run() {
|
||||
if ( allHere ) {
|
||||
stopProgress();
|
||||
}
|
||||
if ( success ) {
|
||||
DbgUtils.showf( BoardActivity.this,
|
||||
R.string.invite_success );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SMSService extends Service {
|
|||
|
||||
// All messages are base64-encoded byte arrays. The first byte is
|
||||
// always one of these. What follows depends.
|
||||
private enum SMS_CMD { NONE, INVITE, DATA, DEATH, };
|
||||
private enum SMS_CMD { NONE, INVITE, DATA, DEATH, ACK, };
|
||||
|
||||
private int m_nReceived = 0;
|
||||
private static int s_nSent = 0;
|
||||
|
@ -273,6 +273,20 @@ public class SMSService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
private void ackInvite( String phone, int gameID )
|
||||
{
|
||||
ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 );
|
||||
DataOutputStream das = new DataOutputStream( bas );
|
||||
try {
|
||||
das.writeInt( gameID );
|
||||
das.flush();
|
||||
|
||||
send( SMS_CMD.ACK, bas.toByteArray(), phone );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
DbgUtils.logf( "ioe: %s", ioe.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDiedPacket( String phone, int gameID )
|
||||
{
|
||||
ByteArrayOutputStream bas = new ByteArrayOutputStream( 32 );
|
||||
|
@ -374,6 +388,8 @@ public class SMSService extends Service {
|
|||
}
|
||||
String body = Utils.format( this, R.string.new_sms_bodyf, phone );
|
||||
postNotification( gameID, R.string.new_sms_title, body );
|
||||
|
||||
ackInvite( phone, gameID );
|
||||
break;
|
||||
case DATA:
|
||||
gameID = dis.readInt();
|
||||
|
@ -385,8 +401,13 @@ public class SMSService extends Service {
|
|||
gameID = dis.readInt();
|
||||
s_srcMgr.sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
break;
|
||||
case ACK:
|
||||
gameID = dis.readInt();
|
||||
s_srcMgr.sendResult( MultiEvent.NEWGAME_SUCCESS,
|
||||
gameID );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
DbgUtils.logf( "unexpected cmd %s", cmd.toString() );
|
||||
break;
|
||||
}
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue