private void Start() { connectionManagerGameObject = Instantiate(connectionManagerPrefab); connectionManager = connectionManagerGameObject.GetComponent <INetworkConnectionManager>(); connectionManager.OnConnected += OnNetConnected; connectionManager.OnDisconnected += OnNetDisconnected; connectionManager.OnReceive += OnNetReceived; if (runAsServer) { connectionManager.StartListening(serverPort); } else { connectionManager.ConnectTo(serverAddress, serverPort); } }
/// <summary> /// Starts a listening socket on the given port. /// </summary> /// <param name="port">The port to listen for new connections on.</param> public void StartListening(int port) { CreateConnectionManager(); connectionManager.StartListening(port); }