Post new topic Reply to topic  [ 4 posts ] 
Client and server implementation in the same game 
Author Message
User avatar

Joined: Wed Dec 02, 2009 1:17 pm
Posts: 4
Location: Resita, Romania
Post Client and server implementation in the same game
Hello everybody,

I've been struggling with a nasty sittuation the past couple of days and couldn't find anything to solve my problem on the net, so I just think it's natural to try and find some help here.

Here's what I'm working on:

I want to make an website from where you can download games and play them with other people registered to the site. Like a match-making service, the website part (a couple of PHP scripts) it's only used to see who's online, who currently hosts a game and so on. I used cURL to achieve this and it's working great.

Now, I want to test an actual game beeing played over the network, just to see how teh web server works with it. I knew about ZoidCom and worked with it before (in terms of two separate applications, the server and the client) so that's not helping me much in my sittuation. I need both of them in the application so the player can choose to host or join a game.

Still, there's something I'm doing wrong because the application doesn't allways connect (as in one to each other). What I want to find out first is, how does Zoidom detect clients that want to connect to the server.

I'm testing with a console tic-tac-toe game so here's what I do. After connecting to the webserver, I initialize the Server class or the Client class, depending on what the user chooses. After this, I run straight to the game loop, breaking every law of networking I think... What I do is checking for input (x and y coordinates) and send that to the other party (the client or the server). They both check input and apply the modifications on the grid, as well as their own actions. The problem is, that I have to run through the code (calling processInput() and processOutput()) a few times before the client requests a connection, then a few trime to get him connected. Is there a problem if I'm testing this locally? I followed and implemented the "chat" tutorial fine before. I'm passing variables using addInt(whatever, 4). Is 4 to much? I don't know how bits actually work... (I'm guessing 4 means a maximum value of 2^4, but it's just a guess).

Sorry for the very long post for such a trivial problem.

_________________
Image


Wed Dec 02, 2009 2:29 pm
Profile YIM WWW
Site Admin
User avatar

Joined: Thu Jan 29, 2004 6:33 am
Posts: 1060
Post Re: Client and server implementation in the same game
4 bits = (2^4)-1 is the maximum value.

The difference between local and remote testing is that with remote testing the gameloop will run more often in your case before the connection is set up because it takes longer to transmit the packets. Zoidcom detects incoming connections by listening on an UDP socket. So if a client wants to connect, the server receives a packet, then sends a packet back and then once again from the client to the server until the connection is established on both sides (if you use the 0.6 version that is - 0.7 sends more packets).

_________________
Zoidcom 0.6.10 | Check out the new Zoidcom Wiki


Thu Dec 03, 2009 8:15 am
Profile
User avatar

Joined: Wed Dec 02, 2009 1:17 pm
Posts: 4
Location: Resita, Romania
Post Re: Client and server implementation in the same game
So i should call processInput() and processOutput() on both sides for a while, then ZCom_cbConnectionRequest() gets called on server side, ZCom_cbConnectResult() on the client side and only then ZCom_cbConnectionSpawned() back on the server, thus connection is made?

Is it safe to loop a processInput(), processOutput() function until the connection is spawned?

_________________
Image


Thu Dec 03, 2009 9:14 am
Profile YIM WWW
Site Admin
User avatar

Joined: Thu Jan 29, 2004 6:33 am
Posts: 1060
Post Re: Client and server implementation in the same game
Exactly, and yes to everything!

_________________
Zoidcom 0.6.10 | Check out the new Zoidcom Wiki


Thu Dec 03, 2009 11:13 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

{ ASACP_CREDITS } Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forum/DivisionCore.