public static NetServer CreateServer(NetHost host = null) { NetServer instance = CreateInstance <NetServer>(); if (host == null) { host = NetCore.Instance.AddHost(hostName: "NetServer Host"); } instance.Initialize(host); return(instance); }
protected void Initialize(NetHost host) { if (status != Status.Uninitialized) { Log.WTF(this, $"Cannot initialize NetServer, because the status is {status.ToString()}", this); return; } netHost = host; // Bind events netHost.OnConnectEvent.RegisterListenerOnce(HandleClientConnected); netHost.OnDisconnectEvent.RegisterListener(HandleClientDisconnected); netHost.OnDataEvent.RegisterListener(HandleDataReceived); // Set status status = Status.InitializedNotRunning; }
public NetDataFilterHost(NetHost host) { this.host = host; }