Qt server-client game, clients communicate?
-
How about each client sends his position to the server every 20ms (or whatever interval you prefer) and server sends a message to each client every 20ms (or whatever interval you prefer) listing the positions of all players on the map. This should not be too much traffic (unless you plan to have over I don't know 1000 player or something). The best fitting interval in which you send the positions to and from the server might need to be tuned a little by testing. This should also be somehow related to the fps rate you have (the 20ms interval would corelate roughly to a 50 fps rate). Although you don't need to have the same position update rate as you have for your frame update rate (you can interpolate and preestimate new positions depending on the the last received position updates).
-
bjanuario, I'll read up all about SOAP usage in qt, thanks.
-edit1: can't find QT server SOAP example, only libs which i'm kinda afraid of using being relatively new to QT...
-edit2: SOAP uses sth like php POST and GET methods (right?), so every client has to ask server for data which either way all clients need to send to the server... so not only server respons to every data request but also has to store all the data and receive updates... OR i suck at understanding how SOAP works hmmKA510, I'm asking for a method to send and receive those positions from each client to all other,
I understand you recomend using servers TCP connections for this, but then again:
" – using TCP would be rather slow, wouldn’t it ?
– plus server would be under heavy TCP attack all the time, and would still have to redirect all the packets it gets. It could crash easily this way, right? " -
[quote author="comanderv" date="1370852855"]
KA510, I'm asking for a method to send and receive those positions from each client to all other,
I understand you recomend using servers TCP connections for this, but then again:
" – using TCP would be rather slow, wouldn’t it ?
– plus server would be under heavy TCP attack all the time, and would still have to redirect all the packets it gets. It could crash easily this way, right? "[/quote]Sending from client to client instead of client to server does not really reduce the amount of messages being send. This way each client would have to send messages to every other client on the map. So this would in the end result in even more messages being send over the network. The client to client vs client to server approach is more of a design choice. Both have their drawbacks, it depends entirely on your requirements what you should choose. But if you are so concerned with the amount of messages being send the client server approach IMHO is better. Example:
10 clients (client to client approach) : each client has to send 9 messages (to all the other clients) and receives 9 messages from all the other clients.
Total of messages send per update 109 = 90
10 clients (client to server approach): each client sends one message to the server; the server sends 10 messages to all clients; each client receives one message.
Total of messages send per update 101 + 1*10 = 20Are you asking for a different way to send the messages (e.g. UDP instead of TCP clients) ? UDP has the drawback that it does not offer reliable transmission. So you might loose messages without noticing. If that is no problem for you UDP is going to be faster than TCP with small messages (according to "this SO thread":http://stackoverflow.com/questions/47903/udp-vs-tcp-how-much-faster-is-it).
-
KA510, you only took into consideration a situation that there is only one map. What if there are 10 maps with 10 clients each?
10 maps, 10 clients each map (client2client): every client on map sends messages to all other clients on the same map
Total of messages send as you counted: 90
10 maps, 10 cleints each map (cleint2server) server receives 100 messages (10x times 10), processess them indentifying from which map they came and sending back to clients on responding map.
total messages send: 200plus this ways server is on heavy TCP attack all the time and can crash or slow down the communication.
about UDP, yeah it works fine on LAN - tried it but without VLAN its impossible to cast it across WAN, or so i read.
i'm kinda getting settled on this TCP client2client approach but i'm not sure if i would have to forward ports to communicate hmm.
It was all fun and easy when on LAN...anyways thanks for your time
-
You should read this "http://www.kdab.com/kdab-products/kd-soap/":http://www.kdab.com/kdab-products/kd-soap/ , Digia have now a strong partnership with KDAB and I use very often and is very powerful and easy to develop under their framework .
[quote author="comanderv" date="1370852855"]bjanuario, I'll read up all about SOAP usage in qt, thanks.
-edit1: can't find QT server SOAP example, only libs which i'm kinda afraid of using being relatively new to QT...
-edit2: SOAP uses sth like php POST and GET methods (right?), so every client has to ask server for data which either way all clients need to send to the server... so not only server respons to every data request but also has to store all the data and receive updates... OR i suck at understanding how SOAP works hmmKA510, I'm asking for a method to send and receive those positions from each client to all other,
I understand you recomend using servers TCP connections for this, but then again:
" – using TCP would be rather slow, wouldn’t it ?
– plus server would be under heavy TCP attack all the time, and would still have to redirect all the packets it gets. It could crash easily this way, right? "[/quote] -
In case you're having problems with ports and or firewalls maybe "RESTful web services":http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_APIs could be considered. Since they are using the HTTP port 80 you will have no problems with firewalls or blocked ports. Using QNetworkManager I think you could just send simple POST requests.
[quote author="comanderv" date="1370860702"]KA510, you only took into consideration a situation that there is only one map. What if there are 10 maps with 10 clients each?
10 maps, 10 clients each map (client2client): every client on map sends messages to all other clients on the same map
Total of messages send as you counted: 90
10 maps, 10 cleints each map (cleint2server) server receives 100 messages (10x times 10), processess them indentifying from which map they came and sending back to clients on responding map.
total messages send: 200 [/quote]10 maps, 10 clients each map (client2client): each client sends 9 messages, receives 9 messages.
For 10 maps thats 900 messages in the network
10 maps, 10 clients each map (client2server): each client sends one message, receives one message. server sends 100 messages receives 100 messages.
Thats a total of 200 messages in the network. -
thank you guys very much,
i have a lot to read and reconsider,
i'm sure you'll be hearing from me soon,
as for now i have problems with mysql driver on win (i used xubuntu before...) but as soon as i'm done with it i'll start SOAPing and reading and i see i will need to use libraries outsied QT which is a new thing for me,thanks again
-
i started browsing google and stumbled upon "Bonjour":http://doc.qt.digia.com/qq/qq23-bonjour.html and it says it's advertising services without needing to know the machine's IP.
would that settle my (at least for now) imaginary problem with port forwarding? (as far as i know behind NAT all ports and IPs are very different then those seen from outside, right?).
there's also QT's fortune server/client example which i'm sure i can reuse for my needs,has anyone had any experience with this Bonjour/Zeroconf class?
this will help me a lot building a TCP/UPD p2p connections ideal for me.as to SOAP and RESTful i still see too many similarities with PHP way of doing things,
the client asks server, the server gives response - the problem is that the serve has to have the updated data ale the time ... and i only need server to verify clients login and pass, the rest i want the clients to do among each other (send them their position - for now server doesnt need to know them)
plus SOAP only has client side implementation in QT and RESTful i guess does'nt have any. I'm really set on using pure QT and QT libs... hmm