packagecom.yottacode.pictogram.grammar;importandroid.util.Log;importcom.github.nkzawa.emitter.Emitter;importorg.json.JSONException;importorg.json.JSONObject;importcom.yottacode.pictogram.dao.Picto;importcom.yottacode.pictogram.action.Room;/**
* Websocket Vocabulary Room based on Room
* @author Fernando Martinez Santiago
* @version 1.0
*/publicclassVocabularyTalkimplementsEmitter.Listener{privatestaticfinalStringURL="vocabulary";privateRoomroom;iVocabularyListenerlisteners[];publicVocabularyTalk(Roomroom,iVocabularyListenerlisteners[]){this.room=room;this.room.listen(URL,this);this.listeners=listeners;}@Overridepublicvoidcall(Object...args){finalStringparam_action="action";finalStringparam_attributes="attributes";finalStringparam_picto="picto";finalStringparam_picto_id="id";finalStringparam_picto_cat="id_cat";finalStringaction_update="update";finalStringaction_add="add";finalStringaction_delete="delete";JSONObjectmsg=(JSONObject)args[0];try{Stringaction=msg.getString(param_action).toLowerCase();JSONObjectpicto=msg.getJSONObject(param_attributes).getJSONObject(param_picto);JSONObjectattrs_picto=picto.getJSONObject(param_attributes);intpicto_id=picto.getInt(param_picto_id);intpicto_cat=attrs_picto.optInt(param_picto_cat,Picto.NO_CATEGORY);Log.d(this.getClass().getName(),"Received message '"+action+"' for picto "+picto_id+" (cat "+picto_cat+", attrs: "+attrs_picto);for(iVocabularyListenerlistener:this.listeners)listener.change(action.equals(action_update)?iVocabularyListener.action.update:action.equals(action_add)?iVocabularyListener.action.add:iVocabularyListener.action.delete,picto_cat,picto_id,attrs_picto);}catch(JSONExceptione){Log.e(this.getClass().getCanonicalName(),e.getClass().getCanonicalName()+"--"+e);}}}
\ No newline at end of file
packagecom.yottacode.pictogram.grammar;importandroid.util.Log;importcom.github.nkzawa.emitter.Emitter;importorg.json.JSONException;importorg.json.JSONObject;importcom.yottacode.pictogram.dao.Picto;importcom.yottacode.pictogram.action.Room;/**
* Websocket Vocabulary Room based on Room
* @author Fernando Martinez Santiago
* @version 1.0
*/publicclassVocabularyTalkimplementsEmitter.Listener{privatestaticfinalStringURL="vocabulary";privateRoomroom;iVocabularyListenerlisteners[];publicVocabularyTalk(Roomroom,iVocabularyListenerlisteners[]){this.room=room;this.room.listen(URL,this);this.listeners=listeners;}@Overridepublicvoidcall(Object...args){finalStringparam_action="action";finalStringparam_attributes="attributes";finalStringparam_picto="picto";finalStringparam_picto_id="id";finalStringparam_picto_cat="id_cat";finalStringaction_update="update";finalStringaction_add="add";finalStringaction_delete="delete";JSONObjectmsg=(JSONObject)args[0];try{Log.i(this.getClass().getName(),"raw Received message "+msg.toString());Stringaction=msg.getString(param_action).toLowerCase();JSONObjectpicto=msg.getJSONObject(param_attributes).getJSONObject(param_picto);JSONObjectattrs_picto=picto.getJSONObject(param_attributes);intpicto_id=picto.getJSONObject(param_picto).getInt(param_picto_id);intpicto_cat=attrs_picto.optInt(param_picto_cat,Picto.NO_CATEGORY);Log.i(this.getClass().getName(),"Received message '"+action+"' for picto "+picto_id+" (cat "+picto_cat+", attrs: "+attrs_picto);for(iVocabularyListenerlistener:this.listeners)listener.change(action.equals(action_update)?iVocabularyListener.action.update:action.equals(action_add)?iVocabularyListener.action.add:iVocabularyListener.action.delete,picto_cat,picto_id,attrs_picto);}catch(JSONExceptione){Log.e(this.getClass().getCanonicalName(),e.getClass().getCanonicalName()+"--"+e);}}}