- Home /
Can't send RPC function since no connection was started.login script
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
/// <summary>
/// Call to chech if client is logged to the server.
/// </summary>
/// <value>
/// <c>true</c> if logged; otherwise, <c>false</c>.
/// </value>
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 () {
}
/// <summary>
/// Send call to login into system with your specified info.
/// </summary>
/// <param name='login'>
/// Login.
/// </param>
/// <param name='password'>
/// Password.
/// </param>
public void Connect(string _login, string password){
networkView.RPC("OnLogin",RPCMode.Server,_login,password);
login = _login;
}
/// <summary>
/// Send call to the server for registration with your info.
/// </summary>
/// <param name='login'>
/// Login.
/// </param>
/// <param name='password'>
/// Password.
/// </param>
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?
i bought this off the unity3d store followed to steps to set it up yet it dont work and how can i format it better i supplyed the file it keeps throwing in the errors and the entire error code what about it cant u understand
You need to format your code! If you don't know how (or what that means) watch the tutorial video on the right :)
Answer by Karma1989 · Jul 22, 2013 at 03:56 AM
i bought this off the unity3d store followed to steps to set it up yet it dont work and how can i format it better i supplyed the file it keeps throwing in the errors and the entire error code what about it cant u understand