예제 #1
0
        public void GetCreatedLobbyData()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    foreach (KeyValuePair <string, string> data in client.Lobby.CurrentLobbyData.GetAllData())
                    {
                        if (data.Key == "appid")
                        {
                            Assert.IsTrue(data.Value == "252490");
                        }
                        Console.WriteLine($"{data.Key} {data.Value}");
                    }
                    client.Lobby.Leave();
                };

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 3)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }
            }
        }
예제 #2
0
        public void CreateLobby()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    Console.WriteLine($"Owner: {client.Lobby.Owner}");
                    Console.WriteLine($"Max Members: {client.Lobby.MaxMembers}");
                    Console.WriteLine($"Num Members: {client.Lobby.NumMembers}");
                    client.Lobby.Leave();
                };

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 3)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }
            }
        }
예제 #3
0
        public void SetGetUserMetadata()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    client.Lobby.SetMemberData("testkey", "testvalue");
                };

                client.Lobby.OnLobbyMemberDataUpdated = (steamID) =>
                {
                    string name = client.Friends.GetName(steamID);
                    Console.WriteLine(name + " updated data");
                    Assert.IsTrue(client.Lobby.GetMemberData(steamID, "testkey") == "testvalue");
                    Console.WriteLine("testkey is now: " + client.Lobby.GetMemberData(steamID, "testkey"));
                };

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 5)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }

                client.Lobby.Leave();
            }
        }
예제 #4
0
        public void RefreshLobbyListWithFilterAndGetLobbyDataFromListLobby()
        {
            using (var client = new Facepunch.Steamworks.Client(755870))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    client.Lobby.CurrentLobbyData.SetData("testkey", "testvalue");
                };

                client.Lobby.OnLobbyDataUpdated = () =>
                {
                    var filter = new LobbyList.Filter();
                    filter.StringFilters.Add("testkey", "testvalue");
                    client.LobbyList.Refresh(filter);
                };

                client.LobbyList.OnLobbiesUpdated = () =>
                {
                    Console.WriteLine("lobbies updating");
                    if (client.LobbyList.Finished)
                    {
                        Console.WriteLine("lobbies finished updating");
                        Console.WriteLine($"found {client.LobbyList.Lobbies.Count} lobbies");

                        foreach (LobbyList.Lobby lobby in client.LobbyList.Lobbies)
                        {
                            foreach (var pair in lobby.GetAllData())
                            {
                                Console.WriteLine(string.Format("Key: {0,-36} Value: {1}", pair.Key, pair.Value));
                            }
                        }
                    }
                };

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 5)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }

                client.Lobby.Leave();
            }
        }
예제 #5
0
    private void Update()
    {
        if (client == null)
        {
            return;
        }

        try {
            UnityEngine.Profiling.Profiler.BeginSample("Steam Update");
            client.Update();
        } finally {
            UnityEngine.Profiling.Profiler.EndSample();
        }
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        if (client == null)
        {
            return;
        }

        try {
            UnityEngine.Profiling.Profiler.BeginSample("Steam Update");
            //getAchievementCount();
            client.Update();
        } finally {
            UnityEngine.Profiling.Profiler.EndSample();
        }
    }
예제 #7
0
    void Update()
    {
        // Makes sure the steam client gets updated
        if (client == null)
        {
            return;
        }

        try
        {
            UnityEngine.Profiling.Profiler.BeginSample("Steam Update");
            client.Update();
        }
        finally
        {
            UnityEngine.Profiling.Profiler.EndSample();
        }
    }
예제 #8
0
    public static void UpdateClient()
    {
        if (client == null)
        {
            return;
        }

        try
        {
            // UnityEngine.Profiling.Profiler.BeginSample("Steam Update");
            client.Update();
        }
        finally
        {
            // Debug.Log("What the f**k");
            // UnityEngine.Profiling.Profiler.EndSample();
        }
    }
예제 #9
0
        public void SendChatMessage()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);
                string testString = "Hello, World";

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    client.Lobby.CurrentLobbyData.SetData("testkey", "testvalue");
                    client.Lobby.SendChatMessage(testString);
                };

                client.Lobby.OnChatMessageRecieved = (steamID, bytes, length) =>
                {
                    string message = Encoding.UTF8.GetString(bytes, 0, length);
                    Console.WriteLine("message recieved");
                    Assert.IsTrue(message == testString);
                };

                client.Lobby.OnChatStringRecieved = (steamID, message) =>
                {
                    Console.WriteLine("message recieved");
                    Assert.IsTrue(message == testString);
                };

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 5)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }

                client.Lobby.Leave();
            }
        }
예제 #10
0
        public void RefreshLobbyList()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);
                    client.LobbyList.Refresh();
                };

                client.LobbyList.OnLobbiesUpdated = () =>
                {
                    Console.WriteLine("lobbies updating");
                    if (client.LobbyList.Finished)
                    {
                        Console.WriteLine("lobbies finished updating");
                        Console.WriteLine($"found {client.LobbyList.Lobbies.Count} lobbies");

                        foreach (LobbyList.Lobby lobby in client.LobbyList.Lobbies)
                        {
                            Console.WriteLine($"Found Lobby: {lobby.Name}");
                        }

                        client.Lobby.Leave();
                    }
                };

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 3)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }
            }
        }
예제 #11
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("Disposing");

            client.Dispose();
        }

        if (client == null)
        {
            return;
        }

        try
        {
            //UnityEngine.Profiling.Profiler.BeginSample("Steam Update");
            client.Update();
        }
        finally
        {
            //UnityEngine.Profiling.Profiler.EndSample();
        }
    }
예제 #12
0
        public void UpdateLobbyData()
        {
            using (var client = new Facepunch.Steamworks.Client(252490))
            {
                Assert.IsTrue(client.IsValid);

                client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);

                client.Lobby.OnLobbyCreated = (success) =>
                {
                    Assert.IsTrue(success);
                    Assert.IsTrue(client.Lobby.IsValid);
                    Console.WriteLine("lobby created: " + client.Lobby.CurrentLobby);

                    client.Lobby.Name = "My Updated Lobby Name";
                    client.Lobby.CurrentLobbyData.SetData("testkey", "testvalue");
                    client.Lobby.LobbyType  = Steamworks.Lobby.Type.Private;
                    client.Lobby.MaxMembers = 5;
                    client.Lobby.Joinable   = false;

                    foreach (KeyValuePair <string, string> data in client.Lobby.CurrentLobbyData.GetAllData())
                    {
                        if (data.Key == "appid")
                        {
                            Assert.IsTrue(data.Value == "252490");
                        }

                        if (data.Key == "testkey")
                        {
                            Assert.IsTrue(data.Value == "testvalue");
                        }

                        if (data.Key == "lobbytype")
                        {
                            Assert.IsTrue(data.Value == Steamworks.Lobby.Type.Private.ToString());
                        }

                        Console.WriteLine($"{data.Key} {data.Value}");
                    }
                };


                client.Lobby.OnLobbyDataUpdated = () =>
                {
                    Console.WriteLine("lobby data updated");
                    Console.WriteLine(client.Lobby.MaxMembers);
                    Console.WriteLine(client.Lobby.Joinable);
                };



                var sw = Stopwatch.StartNew();

                while (sw.Elapsed.TotalSeconds < 3)
                {
                    client.Update();
                    System.Threading.Thread.Sleep(10);
                }

                client.Lobby.Leave();
            }
        }