don't track and refuse to connect to deleted games: the tracking was

incomplete (didn't persist) and gameIDs couldn't be reused.  Fix later
when it's not blocking development if the feature still makes sense.
This commit is contained in:
Eric House 2014-09-09 07:27:04 -07:00
parent 95eb140461
commit 39b9c32fd7

View file

@ -1,4 +1,4 @@
/* -*- compile-command: "find-and-ant.sh -i debug"; -*- */ /* -*- compile-command: "find-and-ant.sh debug install"; -*- */
/* /*
* Copyright 2010 - 2014 by Eric House (xwords@eehouse.org). All * Copyright 2010 - 2014 by Eric House (xwords@eehouse.org). All
* rights reserved. * rights reserved.
@ -439,6 +439,9 @@ public class BTService extends XWService {
R.string.new_bt_body_fmt, R.string.new_bt_body_fmt,
sender ); sender );
postNotification( gameID, R.string.new_bt_title, body, rowid ); postNotification( gameID, R.string.new_bt_title, body, rowid );
// m_sender.allowReuse( gameID );
// Now: can/should I open the game???
} }
} else { } else {
result = BTCmd.INVITE_DUPID; result = BTCmd.INVITE_DUPID;
@ -467,7 +470,7 @@ public class BTService extends XWService {
+ "gameID of %d", + "gameID of %d",
len, host.getName(), gameID ); len, host.getName(), gameID );
// check if it's still here // check if still here
long[] rowids = DBUtils.getRowIDsFor( BTService.this, long[] rowids = DBUtils.getRowIDsFor( BTService.this,
gameID ); gameID );
boolean haveGame = null != rowids && 0 < rowids.length; boolean haveGame = null != rowids && 0 < rowids.length;
@ -576,13 +579,13 @@ public class BTService extends XWService {
private class BTSenderThread extends Thread { private class BTSenderThread extends Thread {
private LinkedBlockingQueue<BTQueueElem> m_queue; private LinkedBlockingQueue<BTQueueElem> m_queue;
private HashMap<String,LinkedList<BTQueueElem> > m_resends; private HashMap<String,LinkedList<BTQueueElem> > m_resends;
private HashSet<Integer> m_deadGames; // private HashSet<Integer> m_deadGames;
public BTSenderThread() public BTSenderThread()
{ {
m_queue = new LinkedBlockingQueue<BTQueueElem>(); m_queue = new LinkedBlockingQueue<BTQueueElem>();
m_resends = new HashMap<String,LinkedList<BTQueueElem> >(); m_resends = new HashMap<String,LinkedList<BTQueueElem> >();
m_deadGames = new HashSet<Integer>(); // m_deadGames = new HashSet<Integer>();
} }
public void add( BTQueueElem elem ) public void add( BTQueueElem elem )
@ -592,9 +595,9 @@ public class BTService extends XWService {
public void removeFor( int gameID ) public void removeFor( int gameID )
{ {
synchronized( m_deadGames ) { // synchronized( m_deadGames ) {
m_deadGames.add( gameID ); // m_deadGames.add( gameID );
} // }
} }
@Override @Override
@ -727,15 +730,15 @@ public class BTService extends XWService {
private boolean sendMsg( BTQueueElem elem ) private boolean sendMsg( BTQueueElem elem )
{ {
boolean success; boolean success = false;
synchronized( m_deadGames ) { // synchronized( m_deadGames ) {
success = m_deadGames.contains( elem.m_gameID ); // success = m_deadGames.contains( elem.m_gameID );
} // }
MultiEvent evt; MultiEvent evt;
if ( success ) { if ( success ) {
evt = MultiEvent.MESSAGE_DROPPED; evt = MultiEvent.MESSAGE_DROPPED;
DbgUtils.logf( "dropping message because game %X dead", DbgUtils.logf( "dropping message %s because game %X dead",
elem.m_gameID ); elem.m_cmd, elem.m_gameID );
} else { } else {
evt = MultiEvent.MESSAGE_REFUSED; evt = MultiEvent.MESSAGE_REFUSED;
} }