working on sockets on/off bug (ii)

parent 84dbe6ed
...@@ -105,11 +105,14 @@ public class Room { ...@@ -105,11 +105,14 @@ public class Room {
} }
public boolean inRoom() {return this.inRoom;} public boolean inRoom() {return this.inRoom;}
public void listen(String msg, Emitter.Listener listener) { public void listen(String msg, Emitter.Listener listener) {
this.socket.registerMessage(msg, listener);
this.listeners.put(msg, listener); this.listeners.put(msg, listener);
} }
private void listen_again() { private void listen_again() {
for (String msg: this.listeners.keySet()) for (String msg: this.listeners.keySet()) {
Log.i(this.getClass().getName(), "Listening to "+msg);
this.socket.registerMessage(msg, this.listeners.get(msg)); this.socket.registerMessage(msg, this.listeners.get(msg));
}
} }
void subscribe() { void subscribe() {
......
...@@ -201,7 +201,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -201,7 +201,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public void setStudentVocabulary(Vocabulary vocabulary) { public void setStudentVocabulary(Vocabulary vocabulary) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.getCurrentUser().get_id_stu();
int seconds1 = Calendar.getInstance().get(Calendar.SECOND), inserts=0; int seconds1 = Calendar.getInstance().get(Calendar.SECOND);
db.delete("collection", "id_stu=?", new String[] {String.valueOf(id_stu)}); db.delete("collection", "id_stu=?", new String[] {String.valueOf(id_stu)});
ContentValues values=new ContentValues(5); ContentValues values=new ContentValues(5);
values.put("id_stu", id_stu); values.put("id_stu", id_stu);
...@@ -266,7 +266,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -266,7 +266,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
ContentValues values = new ContentValues(1); ContentValues values = new ContentValues(1);
values.put("attributes",attrs); values.put("attributes",attrs);
int updates=db.update("collection",values, "id_stu=? AND id_picto=?", new String[] {Integer.toString(id_stu), Integer.toString(picto_id)}); int updates=db.update("collection",values, "id_stu=? AND id_picto=?", new String[] {Integer.toString(id_stu), Integer.toString(picto_id)});
Log.i(this.getClass().getCanonicalName(),"Modify "+updates+" read only db? "+db.isReadOnly()+" Picto attributes: "+picto_id+" attributes="+attrs); Log.i(this.getClass().getCanonicalName(),"Modify "+updates+" Picto attributes: "+picto_id+" attributes="+attrs);
db.close(); db.close();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment