Example #1
0
        public override void Open(string bindip, ushort port, bool lan)
        {
            if (bindip == "*")
            {
                bindip = "0.0.0.0";
            }
            if (IsHosting)
            {
                return;
            }
            var         ip   = SteamworksCommon.GetUInt32FromIp(bindip);
            EServerMode mode = EServerMode.eServerModeAuthenticationAndSecure;

            //if(lan) mode = EServerMode.eServerModeNoAuthentication;
            if (!GameServer.Init(ip, (ushort)(port + 2), port, (ushort)(port + 1), mode,
                                 GameInfo.VERSION))
            {
                throw new ServerInitializationFailedException("Couldn't start server (Steamworks API initialization failed)");
            }

            SteamGameServer.SetDedicatedServer(!lan);
            SteamGameServer.SetGameDescription(GameInfo.NAME);
            SteamGameServer.SetProduct(GameInfo.NAME);
            SteamGameServer.SetModDir(GameInfo.NAME);
            SteamGameServer.SetServerName(Description);
            SteamGameServer.LogOnAnonymous();
            SteamGameServer.SetPasswordProtected(false); //Todo
            SteamGameServer.EnableHeartbeats(true);

            Application.targetFrameRate = 60;
            IsHosting = true;
        }
Example #2
0
 public override bool IsFavoritedServer(string ip, ushort port)
 {
     for (var game = 0; game < SteamMatchmaking.GetFavoriteGameCount(); game++)
     {
         AppId_t appIdT;
         uint    pnIp;
         ushort  connPort;
         ushort  pnQueryPort;
         uint    punFlags;
         uint    lastPlayedOnServer;
         SteamMatchmaking.GetFavoriteGame(game, out appIdT, out pnIp, out connPort, out pnQueryPort,
                                          out punFlags, out lastPlayedOnServer);
         if (((appIdT != GameInfo.ID) || (pnIp != SteamworksCommon.GetUInt32FromIp(ip))) ||
             (port != connPort))
         {
             continue;
         }
         return(true);
     }
     return(false);
 }
Example #3
0
 public override void FavoriteServer(string ip, ushort port)
 {
     SteamMatchmaking.AddFavoriteGame(GameInfo.ID, SteamworksCommon.GetUInt32FromIp(ip), port, (ushort)(port + 1), 2,
                                      (uint)GetServerRealTime());
 }
Example #4
0
 public override void AttemptConnect(string ip, ushort port, string password)
 {
     CleanupServerQuery();
     _serverQuery = SteamMatchmakingServers.PingServer(SteamworksCommon.GetUInt32FromIp(ip), (ushort)(port + 1), _serverPingResponse);
 }
Example #5
0
 public override void AdvertiseGame(Identity serverID, string ip, ushort port)
 {
     SteamUser.AdvertiseGame((CSteamID)(SteamIdentity)serverID, SteamworksCommon.GetUInt32FromIp(ip), port);
 }