About Store Forum Documentation Contact
Donations:
207$/mo



Post Reply 
Lost connection when changing State
Author Message
laugan Offline
Member

Post: #1
Lost connection when changing State
Hi to all!

I faced the following problem:
I have client and server, client consists of (for example) :

main.cpp // here game starts and connection to server is made
main.h
game.cpp // here is extern state "StartGame"
game.h
server.cpp // here is initialization of Connection to server
server.h // here is initialization of extern Connection to server

so when connection in main.cpp is established everything is great, but when i run command StartGame.set(); connection is lost.

p.s. in main.cpp i create a music and run it, so when i change state music continues playing smile

maybe i'm doing something wrong? smile
05-30-2012 05:49 AM
Find all posts by this user Quote this message in a reply
Daniel Mewes Offline
Member

Post: #2
RE: Lost connection when changing State
What have you done with the connection between establishing and setting the GameStart-state? And maybe you can post the lines where you initialized your connection to the server.
05-30-2012 06:54 AM
Find all posts by this user Quote this message in a reply
laugan Offline
Member

Post: #3
RE: Lost connection when changing State
i didn't do anything with connection.

Code:
SockAddr    server;
server.setHost("127.0.0.1",7777);
connection.clientConnectToServer(server);

maybe it's because server variable is defined in main.cpp?
05-30-2012 07:07 AM
Find all posts by this user Quote this message in a reply
Daniel Mewes Offline
Member

Post: #4
RE: Lost connection when changing State
I don't think that the server variable is the problem.

Did you check the connection state before and after GameStart.set()?
I would guess that the problem is fact that you do nothing with the connection and the connection timed out.
Or that the problem is serversided. I've got this problem some months ago, I've added a method and forgot a break in the switch case, so it continued serversided to the "bye"-Method in update() and closed my connection.
05-30-2012 07:43 AM
Find all posts by this user Quote this message in a reply
laugan Offline
Member

Post: #5
RE: Lost connection when changing State
thanks for your reply. if i remove StartGame.set(); from the code (and nothing more) - connection still exists. it is lost in the moment of switching states... i tried some variants but the result is always the same
05-30-2012 07:50 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Lost connection when changing State
are you deleting connection inside any shut method?
05-30-2012 03:03 PM
Find all posts by this user Quote this message in a reply
laugan Offline
Member

Post: #7
RE: Lost connection when changing State
(05-30-2012 03:03 PM)Esenthel Wrote:  are you deleting connection inside any shut method?

Esenthel, you are genius and i need to work less))))) i checked and of course it is deleted in main.cpp in section void ShutMain()

my fault, thanks for help smile
05-30-2012 05:55 PM
Find all posts by this user Quote this message in a reply
Post Reply