Posted: 23rd Dec 2011 1:36
So, I was able to create a server app on my computer that stores high scores. My AppGameKit game submits high scores to it locally and it works. Here's how I create the network locally in the server app:

iNetID = HostNetwork("myNetwork", "Server", 4100)
do
...
loop

And my game app does this:

Function SubmitScore()
iNetID = JoinNetwork("myNetwork", "Client"+str(Random()))
...
EndFunction

I now want to make it so my phone can submit the scores to my server app. I checked my computer IP address (let's say it's 55.55.55.55). I went to my router and forwarded port 4100 to my computer (192.168.1.123).

My server app now looks like this:

iNetID = HostNetwork("55.55.55.55", "Server", 4100)
do
...
loop

And:

Function SubmitScore()
iNetID = JoinNetwork("55.55.55.55", 4100, "Client"+str(Random()))
...
EndFunction

Doesn't see the submitted score. Has anyone else done this? Is there something simple I'm doing wrong? Is there an easy way to test if port 4100 is forwarding to my App?
Posted: 23rd Dec 2011 2:23
Have you unblocked port 4100 at the router?

Drop any firewall's etc to see if this is your problem
Posted: 23rd Dec 2011 4:49
I checked my router and it's not blocking those ports. I checked my firewall and I can see an event trigger for it, but still no luck.
Posted: 23rd Dec 2011 18:53
I have an update. Unfortunately, I'm even more confused. The server all is configured as I describe above. I created a test application as I did above and it works. I put the code in a loop and it submits high scores every 5 seconds.

I then installed it on my Android phone and turned off Wi-Fi on my phone. And it worked! So, I thought I was home free.

I then added the function to my game. I copied the exact same function (which generated random high scores and submits) but it just does not connect. Exact same function code. One works and the other doesn't. Is there setting in my game that might prevent it from connecting like my sample app?

Here's the function I wrote to test:

+ Code Snippet
do
    SubmitScore()
loop

Function SubmitScore()
    t# = timer()
    do
        iNetID = JoinNetwork("55.55.55.55", 4100, "Client"+str(Random()))
        //iNetID = JoinNetwork("myNetwork", "Client"+str(Random()))

        if iNetID > 1 then exit
        if timer() - t# > 4.0
            exit
        endif
    loop

    c = 0
    if iNetID > 0
        // If we don't connect within 4 seconds, print an error and exit
        t# = timer()
        do
            c = GetNetworkNumClients(iNetID)
            if c > 1 then exit
            if timer() - t# > 4.0
                exit
            endif
        loop
    endif

    If c > 1
        ServerID = GetNetworkServerID(iNetID)
        newMsg = CreateNetworkMessage()

        // Add the packet identifier
        AddNetworkMessageFloat(newMsg, 1.1)

        // Add the player's initials
        AddNetworkMessageString(newMsg, "badkneecap")

        // Add the player's score
        AddNetworkMessageInteger(newMsg, Random(100, 5000))

        // Add the player's level
        AddNetworkMessageInteger(newMsg, Random(1, 15))

        // Send it to the server
        SendNetworkMessage(iNetID, ServerID, newMsg)

        //CloseNetwork(iNetID)
    endif

    t# = timer()
    do
        if timer() - t# > 5.0
            exit
        endif
    loop

    if iNetID > 0
        CloseNetwork(iNetID)
        iNetID = 0
    endif
EndFunction


In my game, I simply called the function to submit a random hight score, but it just does not want to connect. Does anyone have any idea why one app wound work and the other not? I'm running them both locally on my computer.
Posted: 24th Dec 2011 15:46
Another update. I took the function to submit the high score and moved it directly into my code and it worked. So, this fixed my problem, but it makes me wonder why.

So, this is what I had that doesn't work:

+ Code Snippet
do
  function1()
  ...
loop

function1()
  SubmitScore()
endfunction

Function SubmitScore()
  ...
EndFunction


When run like this, it doesn't work. If I move the code in "Function SubmitScore()" directly into "function1()", it works.

Has anyone else come across anything like this?
Posted: 26th Dec 2011 1:12
That is very odd? and not come across anything like that?!

You are forced to call the function from within a function to male it work?

Good thinking outside the box to even try this approach. Will keep this 'chestnut' as a short term work around.

Nice fine and not giving up
Posted: 26th Dec 2011 20:13
Actually, it's just the opposite. I had a function call another function and it was not working. So, I took it out of the second function and put it directly into my code and it worked.

AGK, any ideas why it would not work when a function called another function?
Posted: 27th Dec 2011 22:02
I feel like an idiot! This was bothering me, so I kept debugging and I found the problem. I created a file to hold my new function but renamed it. I was including the original file that did nothing, so that's what I got... nothing. Problem solved. Hope others might learn from this rookie mistake!