Http connection is delaying canvas.keypressed

Hello all!

I havn’t been back here for quite some time, but I have one that is stumping me for the moment. My name is Adam Schmelzle, and I have been making J2ME games for a while(Attack Chopper 1/2, Attack Breaker Pro, Attack Brain), so I’m not really new to this.

I am working on an online system for my next game, and all my messaging is done through an HttpConnection for now. I am trying to make this compatible with Midp1.0, which is why I am using http. I have everything working fine on the Sun WTK25, but when it comes to using my phones, I run into problems with my canvas.keypressd() events.

Sometimes the keypresses/releases will work fine, sometimes a delay of a second or two, sometimes it won’t fire until I hit some buttons a few times.

Example 1: So I can press and hold “up”, get the “up-pressed” event, wait a couple seconds then release, but not get the “up-release” event. If I press “up” again I don’t get the “up-pressed” event at all, but when I release I finally get the original “up-release” from the first keypress.

Example 2: Press “up”, get “up-pressed” event. Release “up”, and never get the “released-up” event at all.

This only happens if my network IO thread is sending/receiving data. On one of my phones I experience problems for the entire duration of my game after even doing just 1 httpConnection on the main game thread.

I guess I want to know if anybody has some advice for me regarding network IO. I assume that somewhere along the line the runtime is starving the thread that handles the keypresses, but is there any way to avoid this? Maybe sleeping/waiting briefly(1ms) in the middle of transfering data every once in a while? It does take a second or two to send/recieve.

I plan on implementing socket IO for Midp2.0 phones after I’ve got all the kinks worked out for Midp1.0. My server will use nio, which I have used before in an applet game with positive results.

Help please,
Adam.

Are you not using a thread to handle your network connections?
Making a connection is the most time-consuming part.

Also writing a realtime.multiplayer game for mobile might not be the best idea, nothing personal.
Seeing the problems we have with our messaging client, I would not go down that path.
A TBS or similar game would be a different issue.

Though I’d love to be proven wrong.

Thanks for the reply! I was looking at the timestamps on the most recent posts, and getting discouraged. I’m not doing anything that’s obviously completely silly.

From my own post:

  1. Of course I’m using a separate thread for IO, QUOTE: “This only happens if my network I/O thread is sending/receiving data.” You don’t honestly think somebody that has made even 1 game doesn’t know how to handle I/O?
  2. I didn’t say “real-time” anywhere. I’ve got a 2+sec ping.

With that cleared up, here’s an update: It’s not my fault. That’s right; I purchased a new phone, and it passed with flying colours. Not only that but I ‘hacked’ one of my other phones to remove the ‘network access allowed?’ screen, and the problem magically went away.

So here’s what I think was happening: After the phone’s stupid OS pops up the ‘network allowed?’ screen, it never cleans up after itself properly, and buggers up the keypresses. Since to solve my problem the only thing I did was remove this screen, it’s the obvious culprit. There’s always something wacky when it comes to mobiles.

Don’t take is personally, without the info I have to guess and, well you know the ‘I wanna make an MMO on my mobile’ types :wink:
And the line you re-quoted hinted at sending data each keypress.

And yes, it is your fault. /me jumps behind a large rock :wink:

Ah the permissions and the security system. The royal PITA!
If you want to never see those again you would have to set all permissions (watch out, can have device specific issue) and sign your midlet.
Just setting the permissions lets you get to ‘Ask first time’, signing gets you the ‘never ask me again’:

In the WTK you can set your midelt to manufacturer and it will never ask you.

[quote]There’s always something wacky when it comes to mobiles.
[/quote]
QFT!
And that is why we earn a lot of money for doing this.

Well I still contend that it’s “not my fault”, since it’s not the permissions that cause the problem, but the 'popup ’ screen that is doing the asking. The security question is there to ask the user about allowing the connection, not delaying the keypresses in strange and unpredictable ways.

Chosing “always allow” doesn’t fix the problem with the keypresses, it just lets my connection have permission. Heck, on one phone it asks “always allow” for every connection regardless of the user chosing “yes”. The keypresses are screwy because of the question, not the answer. One of my phones asks permission for every single midi note, no joke.

I can’t sign the apps. I upload them to my advertiser, who in turn ads their advertising code to the app, and then distributes it for free from their site and others. If anyone is going to sign it it’d have to be them, but because this isn’t limited to specific manufacturers/cariers/regions/countries/languages/continents, it’s not really practical.

“And that is why we earn a lot of money for doing this.”, I’m not quite in the “lot of money” category yet myself.

shameless plug Check out http://gamejump.com , my games are actually some of the top ad-revenue generating free games out there. It’s nice to pay the bills while working from home.

We have the permissions and the signing and there are no problems on our side.
Might be a firmware issue? What phone is this?

@Signing:
Ah ok, that changes a lot. I have been down that road.

@Money:
Where are you located? I might have something.

@Plug:
Which ones are yours? I can see my last project from my old comp there as well.

My games are these:

Attack Breaker Pro:
http://www.gamejump.com/gj/jsp/details.jsp?id=315

3D Attack Chopper:
http://www.gamejump.com/gj/jsp/details.jsp?id=127

3D Attack Chopper 2:
http://www.gamejump.com/gj/jsp/details.jsp?id=311

The listings are all done by (#times played) / (#players) for the current month. Currently my best performing game “Attack Breaker Pro” is at #9 in the “Action” category, and #1 for the “puzzle” category for the whole catalog. Actually it’s under-ranked at the moment, 'cause I advertised it a whole bunch at the start of the month which brought up the (#downloads) significantly thus moving my rank lower until the (#plays) evens out again from all the new players. By this time next week, I’ll be back in the overall top 10 list.

AC1 is currently the most downloaded game on getjar.com, and is at #58 in the “Action” category. It’s been that way for a couple months. AC2 doesn’t do nearly as well as AC1, though I like it better, and it’s still new

I have another game: “Attack Brain”:
http://www.gamejump.com/gj/jsp/details.jsp?id=571
, but that was more of a side project I did to show a friend how to make mobile games. His favorite board game is “mastermind”, so we re-made it.

I live in London, Ontario Canada. I’m not really looking for a better paying job, since I’ve only been doing the ad-game thing since September, and I can already bring in enough money to work from home and still pay the bills. Every game I put out brings in more money, so unless I see an amazing job I’m not likely to be enticed.

nice. Attack Chopter looks like a game for me. :slight_smile:

For the life of me I cannot figure out to get the listing. Or are the categories done this way?
Funky Monkey was my last project at HandyGames.

Unfortunetly Canada is slightly off the map for people we are looking for.

The listings arn’t numbered on the site. They are however completely ordered from left->right, top->bottom. #1 in top-left, #2,3, on top row, 4,5,6 next row etc…

This is a recent development. They only started ordering all the listings within the categories this way a month or so ago. Up until then they didn’t have an automated way to rank the games. So any category you pick will have all the games listed in order, just not numbered.

I’d love to hear some feedback from a developer on any of my games. Please come and post on my messageboard:

http://attackgames.proboards84.com

I’m always updating it with my current progress, and asking for input from players, though it’s a bit difficult getting others to post .

@People not commenting:
Might be because there is a problem with the registration.
I get a “It appears that you attempted to register for this forum using the wrong form. Please use the form below to register.”

MIght have some ideas for future games.

I had no idea that there might have been a problem with registration. Thanks for pointing that out. Unfortunately it’s a free board (ProBoards), and I can’t really fix any problems that pop up beyond the admin settings.

EDIT I had a go at creating a new user, and didn’t have any trouble. Hmm, very puzzling.