I’m receiving two error codes and my scene is very simple. Just trying to connect to a host. Very simple stuff. Here is my code for both the Server and Client.
Server:
#pragma strict
var accounttools : GameObject;
var loginhost : GameObject;
//Hidden Variable List
@System.NonSerialized
var LSC_Timer : float = 0;
@System.NonSerialized
var IC_Timer : float = 0;
@System.NonSerialized
var InternetStatus : String = "Testing";
@System.NonSerialized
private var hostdata : HostData[];
@System.NonSerialized
var StartupLoginServer : boolean = false;
//Visible Variable List
var gameName : String = "Rogue_Republic_Test";
// Script Specific Functions
function InternetCheck()
{
// 74.125.224.72 is Google, When we have our own server check against
// its IP to determine internet viability.
var testPing : Ping = new Ping("74.125.224.72");
while(!testPing.isDone)
{
if (IC_Timer > 2)
{
IC_Timer = 0;
InternetStatus = "Internet Unavailable";
Debug.Log(InternetStatus);
return;
}
IC_Timer += Time.deltaTime;
yield;
}
InternetStatus = "Internet Available";
Debug.Log(InternetStatus);
}
function OnMasterServerEvent (mse:MasterServerEvent) {
if ( mse == MasterServerEvent.RegistrationSucceeded ) {
Debug.Log("Login Server Online");
accounttools.active = true;
loginhost.active = true;
}
if ( mse == MasterServerEvent.RegistrationFailedGameName ||
mse == MasterServerEvent.RegistrationFailedGameType ||
mse == MasterServerEvent.RegistrationFailedNoServer )
{
Debug.Log("Login Server Failure.");
}
}
// Core Functions
function Start ()
{
InternetCheck();
}
function Update ()
{
//If internet is available start the login server.
if (InternetStatus == "Internet Available")
{
Debug.Log("Starting Login Server");
Network.InitializeServer (32, 24001, !Network.HavePublicAddress());
MasterServer.RegisterHost( gameName, "RR_Test_Login_Server", "Server Data Placeholder");
InternetStatus = "Login Server is being Resolved";
}
}
And this is for the Client:
var playertestobj : Transform;
var playerinstantiated : boolean = false;
//Hidden Variable List
//@System.NonSerialized
var LSC_Timer : float = 0;
//@System.NonSerialized
var IC_Timer : float = 0;
//@System.NonSerialized
var InternetStatus : String = "Testing";
//@System.NonSerialized
var Refreshing : boolean = false;
@System.NonSerialized
private var hostdata : HostData[];
@System.NonSerialized
var ConnectToLogin : boolean = false;
//Visible Variable List
var gameName : String = "Rogue_Republic_Test";
// Script Specific Functions
function InternetCheck()
{
// 74.125.224.72 is Google, When we have our own server check against
// its IP to determine internet viability.
var testPing : Ping = new Ping("74.125.224.72");
while(!testPing.isDone)
{
if (IC_Timer > 2)
{
IC_Timer = 0;
InternetStatus = "Internet Unavailable";
Debug.Log(InternetStatus);
return;
}
IC_Timer += Time.deltaTime;
yield;
}
InternetStatus = "Internet Available";
Refreshing = true;
Debug.Log(InternetStatus);
}
function refreshHostList() {
MasterServer.ClearHostList();
MasterServer.RequestHostList("Rogue_Republic_Test");
}
@RPC
function login () {
}
// Core Functions
function Start ()
{
InternetCheck();
refreshHostList();
}
function Update ()
{
//If internet is available grab serverlist, connect to the login server.
if (InternetStatus == "Internet Available")
{
if (Refreshing)
{
if (MasterServer.PollHostList().Length > 0)
{
Refreshing = false;
hostdata = MasterServer.PollHostList();
ConnectToLogin = true;
}
LSC_Timer += Time.deltaTime;
if (LSC_Timer > 10)
{
InternetStatus = "Unavailable";
Refreshing = false;
Debug.Log("Login Server Not Available.");
}
}
if (ConnectToLogin == true)
{
//Host list recieved. Begin connecting to Login Server.
var temp = hostdata.Length;
for ( var i : int = 0; i < temp; i++)
{
Debug.Log(hostdata*.gameName);*
if (hostdata*.gameName == “RR_Test_Login_Server”)
_ {_
_ Network.Connect(hostdata);
Debug.Log(“Connecting to Login Server”);
ConnectToLogin = false;
}
}
}
}*_
* //Now if connection is valid, activate login gui and functions.*
* if (Network.isClient)*
* {*
* if (!playerinstantiated)*
* {*
* Debug.Log(“Connected to Login Server”);*
* //Network.Instantiate(playertestobj, gameObject.transform.position, gameObject.transform.rotation, 0);*
* playerinstantiated = true;*
* }*
* }*
}
Now I’ve been recieving the following two error codes on the client side only:
View ID AllocatedID: 0 not found during lookup. Strange behaviour may occur
&
Received state update for view id’ AllocatedID: 0’ but the NetworkView doesn’t exist
After searching the internet I dug up some confusing stuff about Network.isMessageQueueRunning and Network.SetReceivingEnabled and Network.SetSendingEnabled. It seems the solution might be there, but my randomly pluging it in has not helped.
The server is registering, and showing up on the masterserver so that’s no problem.
I have noted that non of the objects with network view from the server or client appear in the Hierarchy of the other. Which leads me to believe its some sort of a connection problem.
My Debug line inside the “if network.isclient” never executes… which leads me to believe I’m not ever actually connected. However both show a connection in the editor’s stats.
So I’m connected, but i’m not a client, with the client, or something.
Also note: everything in both the server and client has a networkview attached to the object.
I’m really confused as to why this is refusing to work. Any ideas?