Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Two questions regarding Chat and Card based game, pls help.  (Read 1963 times)
azherdev
Customers
Community Member
*****
Posts: 99


« on: July 11, 2005, 12:13:58 PM »

Hi guys and gals,

I am looking into developing a card based game with chat built in.  I need design help in architecture.  Ok, here we go:

1. For the card game itself, if you have one server and 5 clients in one game, what is the best way to transmit data?  I would assume TCP since we wouldn't be transmitting data every 1/10 of a second.  But, should the clients poll every second to see what the state of the game is or should clients establish tcp and maintain it waiting for the server to push data to them?

2. As for the chat.  The chat is done in a room, not on individual basis.  Therefore, should the users poll for new chat strings or should the server have tcp link that pushes data once it comes in?

I want to reduce the amount of bandwith used, so polling every second for new changes could end up with 90% of calls returning no data change (and say 1000 people send 100 bytes to poll ends up with 800kbits used just for polling).  But, is that the correct way or is server pushes the correct way?  This is a MMO game I suppose but it is turn based, so latency and 1 second delay is no big deal.  =)

Are there any examples of this?  I am looking in .net tools right now.

Thank you all for help.

- AlexZ
Logged
AndrewMac
Community Member
*
Posts: 212


« Reply #1 on: July 12, 2005, 02:27:38 AM »

Use a TCP connection, your going to be needing all your data, and in order.

Split your clients up into rooms, only send chat and card data to users in that specific room, theres no need for billy in room b to know what move johny in room a made or said.

As a client sends in data you want to check the integrity of it, as in, could he really make this move? Then if so, send the data to all the clients in the room.

You need to keep your packets as small as possible, so dont send strings, send bytes. Givin that, I don't know what kind of card game your making, but lets say each player lays down 5 cards, which is then sent out to all the clients in the room, well if you used a byte for each one of those, your packets would be about 6 Bytes. First Byte = Packet ID, followed by 5 cards.

Anywho.. its like 4:27 AM .. if you need more help just ask Smiley i'm going to bed.
Logged

azherdev
Customers
Community Member
*****
Posts: 99


« Reply #2 on: July 12, 2005, 10:48:23 AM »

Thanks Andrew.  One question, are we talking about a connected or disconnected model?  I'm sorry, I am relatively new to tcp/ip low level stuff.  I am very used to making soap based apps.

1. Client establishes TCP to server and send "Hi, I want to draw another card"
2. The server responds and sais "ok, here is a card Ace of Spades".
3. Does the client at that point disconnect TCP or is it established for the life of the game?
4. If it does disconnect, how does the server then find the client (dynamic non-public IPs) to push the data to them (the other players in the room need to get the info about the card draw you just made)
5. If it does maintain connection, how many connections can I have per server?  Are there any rules of thumb for this?

And yes, I do believe I will put all the brains on the server.
Logged
Yukito
Community Member
*
Posts: 246


WWW
« Reply #3 on: July 12, 2005, 11:23:10 AM »

erm... i would do

1. Connect to Server... "HI i am azherdev"
2. Save him into some list + the socket he called in
3. client says "i want to draw a card"
(3) the server receives data via socket
4. server says to socket: "okay it is xxx" (this will automatically go to the client)
5. ...

so to tell.. everything works via sockets. if the server pushes data into the socket, the client will get it. as you saved all connected clients (sockets) in a list you can send to each socket the data (but only if they need to know.. so if you have a game with hidden cards, wait until the player drops that card)

dunno where the limit is, but it IS high..

and (okay, my sample says so) wait with quitting the connection till the end of game
Logged

Reality is something for people, who cant handle dragons...
AndrewMac
Community Member
*
Posts: 212


« Reply #4 on: July 12, 2005, 01:36:35 PM »

Keep the clients connected for the duration of the game.

When a connection is established:
-> Login
-> Join Room
-> Send Data to Players In That Room
-> Send Player Data to New Player
-> Wait for Commands.

When a connection is dropped:
-> Send 'Player Left' packet to all remaining players in the room
-> Delete the player and his information.

You may want to setup an array of players or a collection, and store each players information in there, like what cards he or she has, how much money, ect.
Logged

jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #5 on: July 12, 2005, 06:52:10 PM »

Where the girls at, anyway?
Logged

JAbstract.....Don't just imagine, make it happen!
GoodVillain
Community Member
*
Posts: 1631


« Reply #6 on: July 13, 2005, 02:03:27 AM »

Sylvain is a ladies man, they are all hanging on him all the time. It wouldnt hurt to SHARE!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks