I am trying to create my client with the imported lidgren network. When i just try to do a simple connect to the server i will get a compiler error telling me that there is a method missing. I dont know how to go forward from this. Do you guys know what the problem is and how i could fix this.
My Code:
using UnityEngine;
using System.Collections;
using System.Net;
using System.Threading;
using System.IO;
using Lidgren.Network;
public class NetworkHandler : MonoBehaviour
{
NetPeerConfiguration config;
NetClient client;
void Start ()
{
config = new NetPeerConfiguration("castaways");
config.Port = 6112;
config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
client = new NetClient(config);
StartClient();
Connect("localhost",6112);
}
public void Connect(string host, int port)
{
client.Connect(host,port);
}
public void StartClient()
{
Debug.Log("Starting Client");
client.Start();
}
public void ShutDownClient()
{
Debug.Log("Client shutdown");
client.Shutdown("Goodbye");
}
void Update ()
{
}
}
I attached this script to a empty gameObject and i got the following error from it
MissingMethodException: Method not found: ‘System.Threading.Monitor.Enter’.
Lidgren.Network.NetPeer.Start ()
NetworkHandler.StartClient () (at Assets/Scripts/NetworkHandler.cs:34)
NetworkHandler.Start () (at Assets/Scripts/NetworkHandler.cs:20)
Please help
//Cheers