public NetServer(string address, int port, int queueLength, int serverLimit, NetData.MessageDispatcher msgDispatcher, NetData.ConnectionDisconnection disconnectionCall, NetData.ConnectionSuccess connectionCall, bool logging = false, bool exittingPerms = false, NetData.LoggingMethod loggingMethod = NetData.LoggingMethod.Console) { // Init _ipAddress = address; _port = port; _msgDispatcher = msgDispatcher; _backLog = queueLength; _serverLimit = serverLimit; _connectionDisconnection = Destroyer; _topDisconnection = disconnectionCall; _connectionSuccess = connectionCall; _dead = false; _idle = true; _logging = logging; _loggingMethod = _loggingMethod; _exitPerms = exittingPerms; // Server Init if (NetInfo.IsValidIPAddress(_ipAddress)) { _serverSocket.Bind(new IPEndPoint(IPAddress.Parse(_ipAddress), _port)); _serverSocket.Listen(_backLog); } // Listener ListenLoop(); }
private void ServerForm_Load(object sender, EventArgs e) { UpdateActiveUsers(); NetData.MessageDispatcher dispatcher = Listener; NetData.ConnectionSuccess connectionSuccess = Connector; NetData.ConnectionDisconnection disconnected = Disconnector; _netServer = new NetServer(IP_ADDRESS, PORT, 5, 50, dispatcher, disconnected, connectionSuccess, true, false); MessageBox.Show("Server created in " + IP_ADDRESS + " on Port: " + PORT + ", Active Connections: " + _netServer.GetConnectionsCount(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); }