public void InitServer()
        {
            HSteamUser hSteamUser = SteamGameServer.GetHSteamUser();

            this.Self = SteamInternal.FindOrCreateGameServerInterface(hSteamUser, this.InterfaceName);
            if (this.Self == IntPtr.Zero)
            {
                throw new Exception(String.Concat("Couldn't find server interface ", this.InterfaceName));
            }
            this.VTable = Marshal.ReadIntPtr(this.Self, 0);
            if (this.Self == IntPtr.Zero)
            {
                throw new Exception(String.Concat("Invalid VTable for server ", this.InterfaceName));
            }
            this.InitInternals();
            SteamServer.WatchInterface(this);
        }
        public virtual void InitServer()
        {
            var user = SteamGameServer.GetHSteamUser();

            Self = SteamInternal.FindOrCreateGameServerInterface(user, InterfaceName);

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find server interface {InterfaceName}");
            }

            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for server {InterfaceName}");
            }

            InitInternals();
        }
Ejemplo n.º 3
0
        public SteamInterface(bool server = false)
        {
            //
            // If teh client isn't initialized but the server is,
            // try to open this interface in server mode
            //
            if (!SteamClient.IsValid && SteamServer.IsValid)
            {
                server = true;
            }

            var hUser = server ?
                        SteamGameServer.GetHSteamUser() :
                        SteamAPI.GetHSteamUser();

            if (hUser == 0)
            {
                throw new System.Exception("Steamworks is uninitialized");
            }

            Self = server ?
                   SteamInternal.FindOrCreateGameServerInterface(hUser, InterfaceName) :
                   SteamInternal.FindOrCreateUserInterface(hUser, InterfaceName);

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find interface {InterfaceName} (server:{server})");
            }


            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
        }