Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Simple Networking

Author
Message
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 16th Dec 2011 05:29
I'm playing around with the networking and I'm having trouble. I created the server app and ran on my computer. Here's the code:



It creates an array of high scores and display them to the screen. It also checks for a network message. When a message comes, it should display the message and get stuck in the loop.

I have a sample app that I run that connects to the network, and if successful, creates a network message that includes a score and initials. Here's the code:



The app runs, and displays the ServerID the iNetID, so I know it is connecting. But it does not appear that the message is getting sent or received. Not sure which. But the server app never displays the message, so I'm not sure it's getting there. But I do know that it is connecting.

Anyone know what I might be doing wrong?
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 16th Dec 2011 06:57
Just tagging along for now sorry...

badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 19th Dec 2011 03:46
So, I was able to get this to work. So, here is my code:



To get it to work, I had to comment out "DeleteNetworkMessage(newMsg)" and "CloseNetwork(iNetID)".

Can anyone explain this?

Now, when a game ends, it submits the score. It works fine, for the first score only. When I play the game again (without closing the app), it does not submit the score. It only seems to work the first time. Any ideas? Right before I submit the score, I close the connecting and open it again. No luck.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Dec 2011 17:44
You could try only closing the network when the game is closed?

Seems like you are leaving a port open that doesn't get closed when the App is closed.

badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 23rd Dec 2011 00:52
The app was written for a phone, so my initial thinking was that I want to connect, submit the network message that contains my high score, and close it. I dont' want to leave it open all the time.

So, I changed my app so that I dont' close the connection right away, but I put in a small delay and then close. It works as expected. Again, I send the message and close. I do not delete it. And to me, this makes sense. The server app should get the message, process, and then delete the message when it is done with it.

But something doesn't make sense to me. I would think that I could connect, send the message, and close. But if I do this without a delay, the message does not get seen. Is there a way to check if the message was received by the server app before closing? I think that would logically make the most sense. That way, I can send the message and close the connection. Then it would be up to the server app to get the message, process it, and then delete it (even if the connection is not active). Is this how it works, or am I missing something?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Jan 2012 14:47
Sounds like it could do with some kind of GetMessagesRemaining() which returns the number of unsent network messages waiting in the queue, when this returns 0 it will be safe to close the connection. Added to my todo list.
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 7th Jan 2012 18:22
That's exactly what I was looking for. However, I don't recall seeing that in the documentation. I'm running Build: Oct 8, 2011. Is that the latest, or is there something newer?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Jan 2012 15:38
As Paul is "adding it to my to do list" I think we'll need to wait until it's done.
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 8th Jan 2012 21:11
Sorry, I totally misread that response. We'll just have to wait.

Login to post a reply

Server time is: 2024-11-22 20:21:54
Your offset time is: 2024-11-22 20:21:54