looking for "api design ideas" for networking libr

Put your problem here if it does not fit any of the other categories.

looking for "api design ideas" for networking libr

Postby atomhamster » Tue Jun 17, 2008 7:59 pm

hello everyone.
i am new to android (who isn't) and coming primarily from the java mobile area, i got one or two orientation issues. still, i would like to achieve the following:

we already have a working java SE library (as middleware for multiplayer games/apps) and want to make it usable on android. it offers the usual non-blocking methods like login() and sendData() and uses http (we're talking about mobile devices). any data sent by others is fetched and the lib makes a callback to a (single) listener which implements an interface with something like loginCB(). i think you get the idea (ask if not)...

we have a single listener which implements all screens and the like and whic is usually also the "game" screen as well. it reacts to callbacks and events alike, keeping in mind which state it's in to "ignore" or postpone events if needed.

in android, there are usually multiple activities and views and i have difficulties finding the best way to handle the library/network according to androids expectations.

so, i am looking for a reasonable API for android.


my ideas so far:
i could implement an android.application, which implements the listener and then create intents from the callback. that would be fairly complicated (big api, complex data), but would be fairly loose.
or i could tie the application more direct to the views, directly knowing their classes and "relay" callbacks to classes as needed. this way, the login screen could be a tableLayout and the game itself could be graphical or anything. but everyone would just need to relay the callbacks as needed and this is not "android like". the reactions to certain callbacks are then pretty scattered.
another idea: have each activity implement the whole listener and then register all listeners to the application which handles the networking. on callback, each registered activity is called and could react. this could lead to (even more) concurrency.


and that's it. im lost! what else could i do? hand over handles to get the results?
any ideas?

thanks,
atomhamster
atomhamster
Freshman
Freshman
 
Posts: 2
Joined: Tue Jun 17, 2008 7:25 pm

Top

Postby atomhamster » Wed Jun 18, 2008 4:34 pm

im not sure why there is neither a question nor an answer to my question, aside from some views. maybe the question is unclear? but someone might have asked what i want to accomplish. maybe the text of my post is too long anyways ;)


i experimented a bit. you are not allowed to call startActivity() from an android.app.Application without a start-new flag. this means i would start any activity within the app as new each time something happens in the receiving application. that's not exactly what should happen, i guess.

the next best idea (to get anything done) is to minimize the defined callback interface. this could then lead to either solution pretty easily i guess:
a) any activity who wants to get updates registers as listener and gets a callback
b) the application (now being the only class implementing the listener) will "convert" every return to an intent and the activities could work based on these intents. the issue here would be the relative complexity of returned data (when i get highscores, there is a lot to give to the client).


anyone interested in this topic after all?
atomhamster
Freshman
Freshman
 
Posts: 2
Joined: Tue Jun 17, 2008 7:25 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 24 guests