public LocalSteamClient(SteamSockets _transport, uint SteamAppID)
 {
     try
     {
         SteamClient.Init(SteamAppID, false);
     }
     catch (Exception e)
     {
         Debug.LogError($"Steam could not initiialize: {e.Message}");
     }
     transport = _transport;
     if (SteamClient.IsValid)
     {
         Debug.Log("SteamClient initialized");
     }
 }
Ejemplo n.º 2
0
        public Server(
            SteamSockets transport,
            int maxConnections,
            uint steamAppID,
            SteamServerInit init,
            SteamSockets.SocketMode socketMode,
            string serverName
            )
        {
            if (transport.debug)
            {
                Debug.Log($"SteamSockets.Server: Starting");
            }
            networkPort = init.GamePort;
            SteamServer.Init(steamAppID, init, false);
            SteamServer.ServerName = serverName;
            if (String.IsNullOrEmpty(transport.gsToken))
            {
                Debug.Log($"No gsToken provided, logging on anonymously");
                SteamServer.LogOnAnonymous();
            }
            else
            {
                Debug.Log($"Logging on with gstoken");
                // Todo: Add SteamServer.LogOn(gsToken); when Facepunch.Steamworks supports it
            }
            if (transport.debug)
            {
                Debug.Log($"Creating socket manager ({socketMode})");
            }
            switch (socketMode)
            {
            case SteamSockets.SocketMode.P2P:
                socketManager = SteamNetworkingSockets.CreateRelaySocket <FPSocketManager>();
                break;

            case SteamSockets.SocketMode.UDP:
                socketManager = SteamNetworkingSockets.CreateNormalSocket <FPSocketManager>(NetAddress.AnyIp(networkPort));
                break;
            }
            socketManager.transport = transport;
        }
Ejemplo n.º 3
0
        public Client(SteamSockets transport, string address, SteamSockets.SocketMode socketMode)
        {
            if (transport.debug)
            {
                Debug.Log($"SteamSockets.Client: Starting");
            }
            if (transport.debug)
            {
                Debug.Log($"Creating connection manager ({socketMode})");
            }
            switch (socketMode)
            {
            case SteamSockets.SocketMode.P2P:
                if (transport.debug)
                {
                    Debug.Log($"Connecting to P2P server steamid {address}");
                }
                SteamId connectSteamId = new SteamId();
                connectSteamId.Value = Convert.ToUInt64(address);
                connectionManager    = SteamNetworkingSockets.ConnectRelay <FPConnectionManager>(connectSteamId);
                break;

            case SteamSockets.SocketMode.UDP:
                string[]   ipPort     = address.Split(':');
                NetAddress netAddress = NetAddress.From(ipPort[0], Convert.ToUInt16(ipPort[1]));
                if (transport.debug)
                {
                    Debug.Log($"Connecting to UDP server {netAddress}");
                }
                connectionManager = SteamNetworkingSockets.ConnectNormal <FPConnectionManager>(netAddress);
                break;
            }
            connectionManager.transport = transport;
            if (transport.debug)
            {
                Debug.Log($"Connecting: {connectionManager.Connecting} Connected: {connectionManager.Connected}");
            }
        }