Hi,
I have two locally connected applications, one being the server, the other being the client. It always worked with my differents builds but this time I have the strangest error:
I don’t have any messages in the console saying that a player has connected/disconnected, I only have “Server created” and this error. I should say that both applications works perfectly independently …
Here’s my code:
Server:
using UnityEngine;
using System.Collections;
using System.Diagnostics;
using UnityEngine.UI;
public class ServerPropsMVR : MonoBehaviour {
/* VARIABLES */
int nbClient = 5;
int nbPort = 25000;
bool useNat = false;
public Text connexionStatusText;
int playerCount;
/* INITIALISATION */
void Start (){
playerCount = 0;
Network.InitializeServer (nbClient,nbPort,useNat);
Process.Start("MVR_Oculus_AsClient");
}
/* MESSAGES */
void OnServerInitialized () {
UnityEngine.Debug.Log ("Server created");
}
void OnPlayerConnected () {
UnityEngine.Debug.Log ("Client connected");
playerCount++;
if (playerCount > 0) {
connexionStatusText.text = "Connected";
connexionStatusText.color = Color.green;
}
}
void OnPlayerDisconnected () {
UnityEngine.Debug.Log ("Client disconnected");
playerCount--;
if (playerCount < 1) {
connexionStatusText.text = "Disconnected";
connexionStatusText.color = Color.red;
}
}
}
Client:
using UnityEngine;
using System.Collections;
public class ClientPropsMVR : MonoBehaviour {
// Server properties
string serverIP = "127.0.0.1";
int serverPort = 25000;
/* INITIALISATION */
void Update(){
if (Network.peerType == NetworkPeerType.Disconnected)
Network.Connect(serverIP, serverPort);
}
/* MESSAGES */
void OnConnectedToServer () {
Debug.Log ("Connected to server");
}
void OnApplicationQuit () {
Network.Disconnect (200);
}
}