- Home /
client to client ping - NAT punchthrough
Hi, is there any way to get client A to client B ping when they are connected to the same server?
I need a way to get the direct ping from client A to client B, without going through the server.
Can client A get the NetworkPlayer of client B, and use GetAveragePing(client B)?
Or is Ping(client B) the only way? Because I believe client A is able to join client B if client B hosts a server, but client A is unable to use Ping(client B). This could be because when joining client B (server), NAT punchthrough is used, and when using Ping(), there is no NAT punchthrough.
Can I use RPC call from client A to client B? Does the RPC go directly from A to B, or does it go from A to MasterServer / Server to B? What is the real route?
Any ideas? Thanks for help!
- Edit: (Sorry, I'll be more specific to my problem)
Here is the problem I am having: (in steps)
1) A hosts a server.
2) B is able to join A with NAT punchthrough.
3) A shuts down the server.
4) A joins server C.
5) B joins server C.
6) B cannot Ping(A.ipAddress) in server C, because A does not have a public IP and A is behind a NAT.
How can I make B ping A directly when they are both on server C?
Or is it correct for B to do Ping(A.externalIP) in such a situation, which will give the proper ping value from B to A?
Answer by Fattie · Oct 26, 2012 at 09:41 AM
Please note - it turns out that this answer is not of much value for Initials actual question, but has some general info.
PRIME has included some extremely important info in his critical comments below. Hope it helps someone in the archived future :O
Well there is only one (1) way to do any networking in Unity!
Simply use the RPC call
http://answers.unity3d.com/questions/332027/call-a-rpc-on-all-clients-at-the-same-time.html
pls vote that answer up if useful :)
When you say "server" there is a confusion:
Say four iPads are playing your game.
firstly you could mean the "boss" iPad which controls the others. If so, I strongly recommend you DO go via the "boss" iPad, but you don't have to.
(Let me put it this way. For any real world networked gaming, the "boss" controls everything. Sure, as a technical demo, you can send a ping between any pair.)
secondly you could mean "a server on the internet", like SmartFox or whatever.
There is absolutely no obligation at all to use a "a server on the internet" for multidevice gaming.
(Personally, I hate it - I only like MP games that allow ordinary "local networking" with your buddies in the room.)
If you do mean "a server on the internet" (A) there is utterly no reason to even use a "a server on the internet", and (B) if you are using a "a server on the internet", yes it is still possible and the norm to talk directly among the iPads, you don't go via the "server on the internet".
Again you just use RPC
that's the SECOND VERSION of RPC on the manual page...
for networking in Unity.
Here is the manual page
http://docs.unity3d.com/Documentation/ScriptReference/NetworkView.RPC.html
When I say server, I meant someone who used initializeServer().
Thanks for trying to help, but I still do not have the answer I need.
A uses initializeServer, B joins A, and C joins A. How can B do a ping to C?
use an RPC call
Notice the enormous, large-type headline in the answer :)
So when B does an RPC call to C, it sends directly from B to C? or does it go from B to A to C?
if you want to, you can definitely send from B to C directly.
YES
To be clear, as a rule you would not do this - you'd never have any reason to do this - in a typical real complex $$anonymous$$P RT networked game.
" I strongly recommend you DO go via the "boss" iPad, but you don't have to (Let me put it this way. For any real world networked ga$$anonymous$$g, the 'boss' controls everything. Sure, as a technical demo, you can send a ping between any pair.)"
Thank you, if it is true that B can send RPC calls to C directly, my issues are solved.
I am doing this because I am making a matchmaking server, where all players join the server, and ping each other to get the best peer.
In the same example, can B use Network.GetAveragePing(NetworkPlayer C) to get the ping?
Your answer
Follow this Question
Related Questions
Networking RPC calls never sent to other clients 1 Answer
network.RPC behavior 1 Answer
RPC is called but it doesn't destroy some GameObject instances 1 Answer
RPC Call Mix Up Issues 0 Answers
Spawning Clients 1 Answer