Example #1
0
        internal ClientInternal(NetworkManager manager, int clientIndex)
        {
            Client = new Client(clientIndex, 0);

            ReceiveEventArgs.Completed += (o,e) => manager.Callback_Receive(this);
            SendEventArgs.Completed += (o, e) => manager.Callback_DataSent(this);
        }
Example #2
0
        /// <summary>
        /// Starts listening to TCP/IP connections on given local port.
        /// <remarks>Every accepted client will be reported through the client accepted handler. Closing of the communication with the    client is reported through the disconnection handler, which is called just once for every client.</remarks>
        /// </summary>
        /// <param name="localPort">Number of given local port where listening will be started.</param>
        public void StartListening(int localPort)
        {
            if (_clientAcceptedHandler == null || _clientDisconnectedHandler == null)
                throw new NotSupportedException("Cannot start listening without client handlers.");

            if (_dataReceivedHandler == null || _dataBlockSentHandler == null)
                throw new NotSupportedException("Cannot start listening without data handlers.");

            if (Network != null)
                throw new NotSupportedException("Cannot start listening twice.");

            Configuration.Freeze();
            Network = new NetworkManager(this);
            Network.StartListening(localPort);
        }