예제 #1
0
    /// <summary>
    /// Server start with address and port binding, password and maximum number of connections
    /// </summary>
    /// <param name="address">bind server to ip</param>
    /// <param name="port">bind server to port</param>
    /// <param name="password">connection password</param>
    /// <param name="max_connections">maximum clients</param>
    /// <param name="insecure">if true, the server will not use security features (encryption, etc.), it is recommended to set false to prevent packet interception</param>
    /// <returns></returns>
    public StartupResult StartServer(string address, ushort port, string password = "", ushort max_connections = 10, bool insecure = false)
    {
        StartupResult result = peer.StartServer(address, port, max_connections, insecure);

        if (result == StartupResult.RAKNET_STARTED)
        {
            peer.SetPassword(password);
            OnServerStart();
            IsRunning = true;
            return(result);
        }
        OnServerStartFailed(result);
        return(result);
    }