Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by SirGive · Dec 08, 2010 at 10:14 PM · networkrpcclientspecific

RPC calls to a specific client?

Now I understand for the most part how RPC's work. The only issue i'm having is singling out a specific client. I think this code does that:

networkView.RPC("someFunction", Network.connections[i]);

@RPC function someFunction() { }

But I'm not sure how exactly to get the id for a specific client. How do I find the right connection?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Oct 19, 2012 at 06:57 AM 0
Share

TBC you must look at the SECOND, BOTTO$$anonymous$$ function on the RPC manual page.

that's the key.

(the first version of the function, mentioned at the top, is of little practical use in typical networking coding.)

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Statement · Dec 08, 2010 at 10:41 PM

But I'm not sure how exactly to get the id for a specific client. How do I find the right connection?

What do you mean by "right connection"? If you want to send the RPC to a client with a specific IP (C#):

foreach (NetworkPlayer player in Network.connections)
{
    if (player.ipAddress == matchingIp)
    {
        networkView.RPC("someFunction", player);
    }
}

You can probably figure out how to replace the comparison test with something more specific for your problem.

For your updated comment I think you need to do something similar like this in your code:

[RPC]
void OnLogin ( string username, string password, NetworkMessageInfo info )
{
    if ( Authenticate( username, password ) )
    {
        networkView.RPC( "OnLoginSuccess", info.sender );
    }
    else
    {
        networkView.RPC( "OnLoginFailure", info.sender );
    }
}
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SirGive · Dec 09, 2010 at 12:11 AM 0
Share

does the RPC function send it directly to the client by IP? I thought that you had to use a specific connection that was identified by Unity. I'm trying to send a flag back to the client. The client sends a log in and password. Thats working fine. I just need the server to send back the flag whether or not the password is taken. I could be wrong, but I don't think that your code will do that specifically. I don't know how to find the connection that the client is identified as.

avatar image Statement · Dec 09, 2010 at 12:55 AM 0
Share

See http://unity3d.com/support/documentation/Components/net-RPCDetails.html, you'll see that you can get a Network$$anonymous$$essageInfo containing the sender (player) of a call. In your OnLogin RPC, you can obtain the sender that way, and respond to only that sender.

avatar image SirGive · Dec 09, 2010 at 06:15 AM 1
Share

That second function is exaclty what I was looking for. Thanks so much :D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Network RPC - exclude specific client 1 Answer

RPC Call Mix Up Issues 0 Answers

Get RPC senders ID, or IP? 1 Answer

client to client ping - NAT punchthrough 1 Answer

Network Instaniate,Lag,Bullet Prefab 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges