Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Can't send RPC function since no connection was started.login script

$
0
0
ok so got the http://u3d.as/content/saulius/login-system/47X i got the server end working fine client side seems it resgisters a username but when i client login or even register get Can't send RPC function since no connection was started. UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) LoginManager:Connect(String, String) (at Assets/LoginClient/Scripts/LoginManager.cs:40) Demo:OnGUI() (at Assets/LoginClient/Scenes/Demo.cs:23) the source to that file is using System.Collections; public class LoginManager : MonoBehaviour { private bool logged = false; private string login; //Setters and getters /// /// Call to chech if client is logged to the server. /// /// /// true if logged; otherwise, false. /// public bool Logged{ get{return logged;} } public string Login{ get{return login;} } // Use this for initialization void Start () { Network.Connect("127.0.0.1", 25001); } // Update is called once per frame void Update () { } /// /// Send call to login into system with your specified info. /// /// /// Login. /// /// /// Password. /// public void Connect(string _login, string password){ networkView.RPC("OnLogin",RPCMode.Server,_login,password); login = _login; } /// /// Send call to the server for registration with your info. /// /// /// Login. /// /// /// Password. /// public void Register(string login, string password){ networkView.RPC("OnRegister",RPCMode.Server,login,password); } public void Disconnect(){ networkView.RPC("OnDisconnect",RPCMode.Server,login); logged = false; } void OnDisconnectedFromServer (NetworkDisconnection info) { Debug.Log ("This CLIENT has disconnected from a server OR this SERVER was just shut down"); //Set client as disconnected. logged = false; } ////////////////////////////////////////////////////////////////////////////////////// //Server [RPC] void OnLogin(string login, string password){ } [RPC] void OnRegister(string login, string password){ } [RPC] void OnDisconnect(string login){ } //Client [RPC] void OnRespond(int respondCode){ Debug.Log("Respond code is: " + respondCode); //Implement your notification system instead the Debug.Log. if(respondCode == 0){ logged = false; Debug.Log("Failed to login."); }else if(respondCode == 1){ Debug.Log("Logged successfully."); logged = true; }else if(respondCode == 2){ Debug.Log("Registered successfully."); }else if(respondCode == 3){ Debug.Log("Failed to register."); } } } any ideas guys?

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>