EncodeURL function

4 views
Skip to first unread message

tarotray

unread,
Sep 10, 2009, 9:06:13 AM9/10/09
to Gamaray

I am currently making a ASP.Net version of the game, as a start for
building a .Net framework, for generating gddf files. I have had total
success, with one exception. When I press an asteroid, the reload
fails.

I seem to have a problem with the refreshURL encoding.

In the source code for the asteroids game, you comment:

// Normally I would use res.encodeURL(url), but for some reason it
wasn't working
// on our production installation of Tomcat, so I made my own
encodeURL() function
// for now.

I have changed your function:

String encodeURL(HttpServletRequest req, HttpServletResponse res,
String url)
{
return url + ";jsessionid=" + req.getSession().getId();
}

into the .Net function:

Private Function EncodeURL(ByVal URL As String) As String

Return URL & ";jsessionid=" &
HttpContext.Current.Session.SessionID.ToString

End Function

I have established that the sessionid generated by this function looks
something like wndqoj55dh1kw145vcp0heqa
and the full URL is reported in the error overlay as:
http://<myserver>/sandbox/asteroidgame/asteroids.gddf?jsessionid=wndqoj55dh1kw145vcp0heqa

If I substitute a ? for the ; , the page loads but without recognizing
the session, so it isn't that.

Have you any advice to offer? Does the Java function req.getSession
().getId() return some different string than the
HttpContext.Current.Session.SessionID.ToString function in .Net (as
shown above)? I shall keep digging deeper, in the meantime.

Suggestion:
May I suggest that, for development purposes, a click on the error
overlay causes a page of more information about the error, such as
stack trace etc., to appear. This will help us developers out here,
who want to use your solidly built API to take AR that one step
further. A 'Could not load...' message is not too much to go by, when
something is wrong and the trial & error testing needed, then, is time-
consuming.

Clayton: You know the translation of <myserver>, above, so you can
test the issue for yourself, if you like.

Clayton Lilly

unread,
Sep 11, 2009, 12:45:36 AM9/11/09
to Gamaray
It would be great to have an ASP.Net version of the demo!

I'll need to look into it further, but I'm guessing ASP.Net uses a
different variable to maintain session, probably not "jsessionid".
According to http://msdn.microsoft.com/en-us/library/aa479315.aspx the
format is:

http://MySite.com/MyWebApplication/(XXXXXXXXXXX)/home.aspx

where XXXXXXXXXXX is the session id.

I don't know much about ASP, but I had assumed there would be an easy
way to rewrite URLs with the session. This may or may turn out to be
the case.

The application definitely does need to a way to give more details for
errors.

tarotray

unread,
Sep 11, 2009, 2:31:31 PM9/11/09
to Gamaray
Clayton, you're a star :-) I can't thank you enough.

That clue led me to hours of trial and error work, but I did succeed,
very late, last night. When I'd broken through that barrier, it seems
my session handling code turned out to be faulty. Converting Java OOP
stuctures to .Net ones is not as easy as it seems, at first. More long
hours have followed - in fact over three hard-coding days, in all.

However... I just had my marvelous 'it works!!!' moment and I have
played a game of Asteroids on my Android that, is actually running
from my .Net server. :-) It was worth the work.

That is stage one complete. Stage two is to turn the, now working,
code into a flexible framework for generating .gddf files.

More of this, as the work progresses.

BTW FYI The sessionid format, for .Net, used to be as you give, but
now is slightly different: http://MySite.com/MyWebApplication/(S(2kgvu0zlr33gyu45qlbuu43x))/home.aspx

Clayton Lilly

unread,
Sep 13, 2009, 11:56:52 PM9/13/09
to Gamaray
That's great! I'm really impressed you were able to convert my Java
code to .Net. Having a .Net sever side framework will really help out.

On Sep 11, 2:31 pm, tarotray <tarot...@gmail.com> wrote:
> Clayton, you're a star :-) I can't thank you enough.
>
> That clue led me to hours of trial and error work, but I did succeed,
> very late, last night. When I'd broken through that barrier, it seems
> my session handling code turned out to be faulty. Converting Java  OOP
> stuctures to .Net ones is not as easy as it seems, at first. More long
> hours have followed - in fact over three hard-coding days, in all.
>
> However... I just had my marvelous 'it works!!!' moment and I have
> played a game of Asteroids on my Android that, is actually running
> from my .Net server. :-) It was worth the work.
>
> That is stage one complete. Stage two is to turn the, now working,
> code into a flexible framework for generating .gddf files.
>
> More of this, as the work progresses.
>
> BTW FYI The sessionid format, for .Net, used to be as you give, but
> now is slightly different:http://MySite.com/MyWebApplication/(S(2kgvu0zlr33gyu45qlbuu43x))/home...

tarotray

unread,
Sep 14, 2009, 12:50:35 AM9/14/09
to Gamaray
Almost complete, Clayton. Let's collaborate. :-)
Reply all
Reply to author
Forward
0 new messages