mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-08 20:46:12 +01:00
pass utilctxt when making new game in response to relay invitation so
the game can communicate. This lets the game reply and otherwise get started the way BT- and SMS-invite-created ones do.
This commit is contained in:
parent
9a7220554f
commit
c9e8655eea
4 changed files with 31 additions and 21 deletions
|
@ -1076,7 +1076,8 @@ public class BTService extends XWService {
|
|||
long[] rowids = DBUtils.getRowIDsFor( BTService.this, nli.gameID() );
|
||||
if ( null == rowids || 0 == rowids.length ) {
|
||||
CommsAddrRec addr = nli.makeAddrRec( BTService.this );
|
||||
long rowid = GameUtils.makeNewMultiGame( BTService.this, nli, m_btMsgSink );
|
||||
long rowid = GameUtils.makeNewMultiGame( BTService.this, nli,
|
||||
m_btMsgSink, null );
|
||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
result = BTCmd.INVITE_FAILED;
|
||||
} else {
|
||||
|
|
|
@ -463,18 +463,20 @@ public class GameUtils {
|
|||
|
||||
public static long makeNewMultiGame( Context context, NetLaunchInfo nli )
|
||||
{
|
||||
return makeNewMultiGame( context, nli, null );
|
||||
return makeNewMultiGame( context, nli, (MultiMsgSink)null,
|
||||
(UtilCtxt)null );
|
||||
}
|
||||
|
||||
public static long makeNewMultiGame( Context context, NetLaunchInfo nli,
|
||||
MultiMsgSink sink )
|
||||
MultiMsgSink sink, UtilCtxt util )
|
||||
{
|
||||
DbgUtils.logf( "makeNewMultiGame(nli=%s)", nli.toString() );
|
||||
CommsAddrRec addr = nli.makeAddrRec( context );
|
||||
|
||||
return makeNewMultiGame( context, sink, DBUtils.GROUPID_UNSPEC, addr,
|
||||
new int[] {nli.lang}, new String[] { nli.dict },
|
||||
nli.nPlayersT, nli.nPlayersH, nli.forceChannel,
|
||||
return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC,
|
||||
addr, new int[] {nli.lang},
|
||||
new String[] { nli.dict }, nli.nPlayersT,
|
||||
nli.nPlayersH, nli.forceChannel,
|
||||
nli.inviteID(), nli.gameID(), nli.gameName,
|
||||
false );
|
||||
}
|
||||
|
@ -505,12 +507,14 @@ public class GameUtils {
|
|||
CommsAddrRec addr = new CommsAddrRec( addrSet );
|
||||
addr.populate( context );
|
||||
int forceChannel = 0;
|
||||
return makeNewMultiGame( context, null, groupID, addr, lang, dict, 2, 1,
|
||||
return makeNewMultiGame( context, (MultiMsgSink)null, (UtilCtxt)null,
|
||||
groupID, addr, lang, dict, 2, 1,
|
||||
forceChannel, inviteID, 0, gameName, true );
|
||||
}
|
||||
|
||||
private static long makeNewMultiGame( Context context, MultiMsgSink sink,
|
||||
long groupID, CommsAddrRec addr,
|
||||
UtilCtxt util, long groupID,
|
||||
CommsAddrRec addr,
|
||||
int[] lang, String[] dict,
|
||||
int nPlayersT, int nPlayersH,
|
||||
int forceChannel, String inviteID,
|
||||
|
@ -543,7 +547,7 @@ public class GameUtils {
|
|||
|
||||
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
|
||||
GameLock lock = new GameLock( rowid, true ).lock();
|
||||
applyChanges( context, sink, gi, addr, inviteID, lock, false );
|
||||
applyChanges( context, sink, gi, util, addr, inviteID, lock, false );
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
@ -595,9 +599,10 @@ public class GameUtils {
|
|||
addr = new CommsAddrRec( null, null );
|
||||
}
|
||||
String inviteID = GameUtils.formatGameID( gameID );
|
||||
return makeNewMultiGame( context, sink, groupID, addr, langa, dicta,
|
||||
nPlayersT, nPlayersH, forceChannel,
|
||||
inviteID, gameID, gameName, isHost );
|
||||
return makeNewMultiGame( context, sink, (UtilCtxt)null, groupID, addr,
|
||||
langa, dicta, nPlayersT, nPlayersH,
|
||||
forceChannel, inviteID, gameID, gameName,
|
||||
isHost );
|
||||
}
|
||||
|
||||
public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli )
|
||||
|
@ -955,13 +960,14 @@ public class GameUtils {
|
|||
CommsAddrRec car, String inviteID,
|
||||
GameLock lock, boolean forceNew )
|
||||
{
|
||||
applyChanges( context, null, gi, car, inviteID, lock, forceNew );
|
||||
applyChanges( context, (MultiMsgSink)null, gi, (UtilCtxt)null, car,
|
||||
inviteID, lock, forceNew );
|
||||
}
|
||||
|
||||
public static void applyChanges( Context context, MultiMsgSink sink,
|
||||
CurGameInfo gi, CommsAddrRec car,
|
||||
String inviteID, GameLock lock,
|
||||
boolean forceNew )
|
||||
CurGameInfo gi, UtilCtxt util,
|
||||
CommsAddrRec car, String inviteID,
|
||||
GameLock lock, boolean forceNew )
|
||||
{
|
||||
// This should be a separate function, commitChanges() or
|
||||
// somesuch. But: do we have a way to save changes to a gi
|
||||
|
@ -988,7 +994,9 @@ public class GameUtils {
|
|||
}
|
||||
|
||||
if ( forceNew || !madeGame ) {
|
||||
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(context),
|
||||
XwJNI.game_makeNewGame( gamePtr, gi, util,
|
||||
JNIUtilsImpl.get(context),
|
||||
(DrawCtx)null,
|
||||
cp, sink, dictNames, pairs.m_bytes,
|
||||
pairs.m_paths, langName );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 - 2012 by Eric House (xwords@eehouse.org). All
|
||||
* Copyright 2010 - 2015 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -251,8 +251,9 @@ public class RelayService extends XWService
|
|||
// connect to the inviting game, because it needs to be open to
|
||||
// make the initial connection -- needs access to util. That
|
||||
// should be fixable -- eventually.
|
||||
RelayMsgSink sink = null; // new RelayMsgSink();
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink );
|
||||
RelayMsgSink sink = new RelayMsgSink();
|
||||
UtilCtxt util = new UtilCtxtImpl( this );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink, util );
|
||||
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
|
||||
if ( null != nli.gameName && 0 < nli.gameName.length() ) {
|
||||
DBUtils.setName( this, rowid, nli.gameName );
|
||||
|
|
|
@ -630,7 +630,7 @@ public class SMSService extends XWService {
|
|||
private void makeForInvite( String phone, NetLaunchInfo nli )
|
||||
{
|
||||
SMSMsgSink sink = new SMSMsgSink( this );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink, null );
|
||||
postNotification( phone, nli.gameID() );
|
||||
ackInvite( phone, nli.gameID() );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue