Page 1 of 2
JBoss, Client-Server connection and Android

Posted:
14 May 2015, 18:45
by Endless
So, for a while now I've been toying with the idea of writing an Android client for Xmage. I'm aware that representing such a complex game on anything smaller than a full-sized monitor is a challenge, to say the least, but I'm fine with that. That's a fun challenge, and for now this is a toy project anyway.
When I approached LevelX with this elsewhere, it was suggested I might have difficulties with JBoss. Guided by this comment, I decided to start by trying to establish a basic connection to one of the servers.
Unsurprisingly, I had difficulties.
I've managed to compile and import MageCommon into an android app, but all of my attempts to start a connection have failed miserably. So, before I go too deep into this, I wanted to ask a couple of question since you certainly know more about this than me.
I apologise if these are stupid questions, I have zero experience with how JBoss works.
- Can the client part of JBoss run on Android or is it just completely incompatible? I'm guessing it's incompatible, but if it's compatible then I can start investigating why I've failed so far.
- If it is incompatible, is it possible for a client to connect to an xmage server without JBoss? Is there a specification of what a client needs to do to connect to an xmage server?
Thanks for any help
Re: JBoss, Client-Server connection and Android

Posted:
15 May 2015, 13:05
by BetaSteward
Hi Endless,
I don't have any experience with coding for Android so I can't speak to why JBoss Remoting doesn't work on that platform. However I can report that I am making good progress on converting the IO framework to Netty which has good Android support. I am currently looking at using plain sockets but I could easily change to using web sockets if it makes it easier for other platforms.
I will be committing my code to a new branch in a few days time. I wouldn't put in any more effort trying to get JBoss Remoting working. Instead you could spend your time getting familiar with Netty.
Regards,
BetaSteward
Re: JBoss, Client-Server connection and Android

Posted:
15 May 2015, 21:24
by LevelX
BetaSteward wrote:Hi Endless,
I don't have any experience with coding for Android so I can't speak to why JBoss Remoting doesn't work on that platform. However I can report that I am making good progress on converting the IO framework to Netty which has good Android support. I am currently looking at using plain sockets but I could easily change to using web sockets if it makes it easier for other platforms.
I will be committing my code to a new branch in a few days time. I wouldn't put in any more effort trying to get JBoss Remoting working. Instead you could spend your time getting familiar with Netty.
Regards,
BetaSteward
Hey that sounds great!
Re: JBoss, Client-Server connection and Android

Posted:
16 May 2015, 08:44
by Endless
Thanks BetaSteward, that's great to hear.
I'll let go of JBoss and keep an eye out for the new branch.
I've never worked with sockets, but doing a little research seems to indicate that plain sockets work fine on android. So just do what works best on your side.
Cheers,
Re: JBoss, Client-Server connection and Android

Posted:
23 May 2015, 14:35
by BetaSteward
Take a look at the new branch Network_Upgrade. It's pretty rough at the moment but you should get an idea of how it will work.
Re: JBoss, Client-Server connection and Android

Posted:
23 May 2015, 16:36
by Endless
Thanks, I'm pulling the branch now. Sadly, I'm swamped with reports to mark so it'll take me some time to dive into it.
Re: JBoss, Client-Server connection and Android

Posted:
24 May 2015, 09:34
by Endless
Quick question.
- I've made a dummy class inheriting network.interfaces.MageClient,
- I pass it to the constructor of the network Client class to create a Client object.
- I call `.connect(...)` on this Client object, and I think this works because the MageClient.connected() method is getting invoked.
What's the minimum number of steps to get some form of chat communication going? Is there a java file you can point me to for that? I'm reading through the code, but I haven't been able to find that part yet.
Cheers,
Re: JBoss, Client-Server connection and Android

Posted:
24 May 2015, 10:01
by Endless
Ok, I think I found the relevant code. From what I understand (correct me if I'm wrong), I need to:
- Get a roomID with the `client.getServerState().getMainRoomId()`.
- Use that to get the room's chat ID with `.getRoomChatId`.
Now the problem I have is that the client's serverState is never set, because its `clientRegistered()` method is never called.
With a little more investigation, it seems that this method is supposed to be called by the `messageReceived()` method of `ClientRegisteredMessageHandler`, but *that* method is never called in the code. So I assume that's what you meant when you said it's still a little rough?

Re: JBoss, Client-Server connection and Android

Posted:
24 May 2015, 14:35
by BetaSteward
Yeah, the code is still a bit rough since there is very little error handling/notification. It is possible that your attempt to connect to the server was unsuccessful or is still pending.
Once the server receives a connect message and creates a session it is supposed to send back the ServerState. In my tests this can take a few seconds to happen since it happens asynchronously. You can try polling the variable for when it becomes non-null. I think I will need to make the connect() call synchronous.
Re: JBoss, Client-Server connection and Android

Posted:
25 May 2015, 15:35
by Endless
Thanks, I found my issue. Things seem to be going forward now.
I can connect to my server and receive chat messages. Now trying to figure out how to send them.
Re: JBoss, Client-Server connection and Android

Posted:
26 May 2015, 17:20
by Endless
That's odd. It was working yesterday, but now it isn't. I've managed to successfully `.connect()` to the server, and then `serverstate.getMainRoomId()`, but when I try to `.getRoomChatId` it just hangs indefinitely.
Do you have any idea why it could be doing that? Did I miss any setup steps?
On a separate note, when running the Mage.Client project, the chat works for a few minutes, and eventually just stops. Could that be related?
Re: JBoss, Client-Server connection and Android

Posted:
26 May 2015, 18:07
by Endless
Ok. It seems to work if I wait a second or two between getting the room id and getting the chat id. Doesn't make much sense to me, since they're both synchronous requests (IIUC), but it could be Android killing the thread or something.
Re: JBoss, Client-Server connection and Android

Posted:
23 Jun 2015, 13:00
by bestdayever
Has any work moved forward on an android client? Is there a repo at this point?
Re: JBoss, Client-Server connection and Android

Posted:
23 Jun 2015, 14:08
by Endless
Yes, there's some work.
Right now it can connect to a server (as long as it's using the new network branch) and chat on the server. It can also view deck files.
I noticed that tables were implemented in network branch a couple of weeks ago, but I've been busy since then so progress has stoped.
I'll push it to github this week if people want to follow/help. But I should warn you it's written in clojure.

Re: JBoss, Client-Server connection and Android

Posted:
23 Jun 2015, 14:18
by bestdayever
How set are you on clojure? I wouldn't mind trying to do it but I'm worried about losing some of the fancier java libs (dagger for DI, etc). Do you have a MVP structure or how would you describe the design pattern? I would love to take a look.