public string FetchMiniProfile(SteamId id, bool client = true, int status = 1)
 {
     string url = "http://steamcommunity.com/miniprofile/" + id.AccountId;
     var data = new Dictionary<string, string>
     {
         {"client", client.IntValue().ToString()},
         {"status", status.ToString()}
     };
     return _web.Fetch(url, "GET", data, null, false).ReadStream();
 }
Exemplo n.º 2
0
 protected override void OnNewConnection(SteamId id) => SteamNetworking.AcceptP2PSessionWithUser(id);
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     return(SteamId.GetHashCode());
 }
Exemplo n.º 4
0
 public Query WhereUserUsedOrPlayed(SteamId user = default)
 {
     userType = UserUGCList.UsedOrPlayed; LimitUser(user); return(this);
 }
Exemplo n.º 5
0
 public Query WhereUserWillVoteLater(SteamId user = default)
 {
     userType = UserUGCList.WillVoteLater; LimitUser(user); return(this);
 }
Exemplo n.º 6
0
 public bool TagUser(SteamId user)
 {
     return(SteamScreenshots.Internal.TagUser(this.Value, user));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Invite another user to the lobby
 /// will return true if the invite is successfully sent, whether or not the target responds
 /// returns false if the local user is not connected to the Steam servers
 /// </summary>
 public bool InviteFriend(SteamId steamid)
 {
     return(SteamMatchmaking.Internal.InviteUserToLobby(Id, steamid));
 }
Exemplo n.º 8
0
        /// <summary>
        ///     重新获取新 Cookies,如果是第一次调用本方法,会同时启用定时检测计时器
        /// </summary>
        public async Task Refresh()
        {
            if (!_checkTimer.Enabled)
            {
                _logger.Info($"#{BotSequenceNumber} Cookies check timer started.");
                _checkTimer.Start();
            }

            if (string.IsNullOrWhiteSpace(WebApiUserNonce))
            {
                return;
            }

            // generate an AES session key
            var sessionKey = CryptoHelper.GenerateRandomBlock(32);

            // RSA encrypt it with the public key for the universe we're on
            byte[] encryptedSessionKey;
            using (var rsa = new RSACrypto(KeyDictionary.GetPublicKey(ConnectedUniverse)))
            {
                encryptedSessionKey = rsa.Encrypt(sessionKey);
            }

            var loginKey = new byte[20];

            Array.Copy(Encoding.ASCII.GetBytes(WebApiUserNonce), loginKey, WebApiUserNonce.Length);

            // AES encrypt the loginkey with our session key
            var encryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey);

            try
            {
                await _retryPolicy.ExecuteAsync(async() =>
                {
                    using (dynamic userAuth = WebAPI.GetAsyncInterface("ISteamUserAuth"))
                    {
                        KeyValue authResult =
                            await userAuth.AuthenticateUser(steamid: SteamId.ConvertToUInt64(),
                                                            sessionkey: HttpUtility.UrlEncode(encryptedSessionKey),
                                                            encrypted_loginkey: HttpUtility.UrlEncode(encryptedLoginKey),
                                                            method: "POST",
                                                            secure: true);

                        _cookieContainer.Add(new Cookie("sessionid",
                                                        Convert.ToBase64String(Encoding.UTF8.GetBytes(LoginKeyUniqueId.ToString())),
                                                        string.Empty,
                                                        "steamcommunity.com"));

                        _cookieContainer.Add(new Cookie("steamLogin", authResult["token"].AsString(),
                                                        string.Empty,
                                                        "steamcommunity.com"));

                        _cookieContainer.Add(new Cookie("steamLoginSecure", authResult["tokensecure"].AsString(),
                                                        string.Empty,
                                                        "steamcommunity.com"));

                        _logger.Info($"#{BotSequenceNumber} Cookies refreshed.");
                    }
                });
            }
            catch (Exception e)
            {
                _logger.Warn($"#{BotSequenceNumber} Cookies refresh failed.", e);
            }
        }
 internal static extern void InternalSetSteamID(ref NetIdentity self, SteamId steamID);
Exemplo n.º 10
0
        /// <summary>
        /// Connect this FacepunchP2PClient to a FacepunchP2PServer hosted by steam user with SteamId specified
        /// </summary>
        /// <param name="hostId">The server's SteamID object</param>
        /// <param name="pendCreates">Immediately set the NetWorker::PendCreates to true</param>
        public void Connect(SteamId hostId, bool pendCreates = false)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException("FacepunchP2PClient", "This object has been disposed and can not be used to connect, please use a new FacepunchP2PClient");
            }

            // By default pending creates should be true and flushed when ready
            if (!pendCreates)
            {
                PendCreates = true;
            }

            try
            {
                ushort clientPort = DEFAULT_PORT;

                // Make sure not to listen on the same port as the server for local networks
                if (clientPort == DEFAULT_PORT)
                {
                    clientPort++;
                }

                Client = new CachedFacepunchP2PClient(hostId);

                // Do any generic initialization in result of the successful bind
                OnBindSuccessful();

                // Get a random hash key that needs to be used for validating that the server was connected to
                headerHash = Websockets.HeaderHashKey();

                // This is a typical Websockets accept header to be validated
                byte[] connectHeader = Websockets.ConnectionHeader(headerHash, DEFAULT_PORT);

                // Setup the identity of the server as a player
                server = new NetworkingPlayer(0, hostId, true, this);

                // Create the thread that will be listening for new data from connected clients and start its execution
                Task.Queue(ReadNetwork);

                //Let myself know I connected successfully
                OnPlayerConnected(server);

                // Set myself as a connected client
                server.Connected = true;

                //Set the port
                SetPort(clientPort);

                int connectCounter = 0;
                Task.Queue(() =>
                {
                    do
                    {
                        // Send the accept headers to the server to validate
                        Client.Send(connectHeader, connectHeader.Length, hostId, P2PSend.Reliable);
                        Thread.Sleep(3000);
                    } while (!headerExchanged && IsBound && ++connectCounter < CONNECT_TRIES);

                    if (connectCounter >= CONNECT_TRIES)
                    {
                        if (connectAttemptFailed != null)
                        {
                            connectAttemptFailed(this);
                        }
                    }
                });
            }
            catch (Exception e)
            {
                Logging.BMSLog.LogException(e);
                // Do any generic initialization in result of the binding failure
                OnBindFailure();

                throw new FailedBindingException("Failed to bind to server's SteamId, see inner exception", e);
            }
        }
Exemplo n.º 11
0
 public ClassStatsViewmodel(SteamId playerId, Classes playerClass)
 {
     PlayerId    = playerId;
     PlayerClass = playerClass;
 }
Exemplo n.º 12
0
        private void SendToId(INetworkMessage msg, MessageSendType send, SteamId id)
        {
            P2PMessage pMsg = msg.MakeMsg();

            playerConnections[id].SendMessage(pMsg, send);
        }
Exemplo n.º 13
0
        private void ServerSendToAllExcept(INetworkMessage msg, MessageSendType send, SteamId except)
        {
            P2PMessage pMsg = msg.MakeMsg();

            foreach (SteamId p in players)
            {
                if (p != except)
                {
                    playerConnections[p].SendMessage(pMsg, send);
                }
            }
        }
Exemplo n.º 14
0
        public override bool Equals(object obj)
        {
            var other = obj as PlayerBans;

            return(other != null && SteamId.Equals(other.SteamId));
        }
Exemplo n.º 15
0
 public void InvalidStringSteam3(string value)
 {
     Assert.False(SteamId.TryFromSteam3(value, out _));
     Assert.Throws <ArgumentException>(() => SteamId.FromSteam3(value));
 }
Exemplo n.º 16
0
        // Constructor
        public PlayerRep(string name, SteamId steamId)
        {
            this.steamId = steamId;

            // Create this player's "Ford" to represent them, known as their rep
            GameObject ford = Instantiate(fordBundle.LoadAsset("Assets/Ford.prefab").Cast <GameObject>());

            // Makes sure that the rep isn't destroyed per level change.
            DontDestroyOnLoad(ford);


            GameObject root     = ford.transform.Find("Ford/Brett@neutral").gameObject; // Get the rep's head
            Transform  realRoot = root.transform.Find("SHJntGrp/MAINSHJnt/ROOTSHJnt");  // Then get the head's root joint


            // Assign targets for the IK system
            GameObject pelvisTarget = new GameObject("Pelvis");

            // Create an anchor object to hold the rep's gun
            gunParent = new GameObject("gunParent");
            gunParent.transform.parent        = realRoot.Find("Spine_01SHJnt/Spine_02SHJnt/Spine_TopSHJnt/r_Arm_ClavicleSHJnt/r_AC_AuxSHJnt/r_Arm_ShoulderSHJnt/r_Arm_Elbow_CurveSHJnt/r_WristSHJnt/r_Hand_1SHJnt");
            gunParent.transform.localPosition = Vector3.zero;
            gunParent.transform.localRotation = Quaternion.identity;

            // If for whatever reason this is needed, show or hide the rep's body and hair
            root.transform.Find("geoGrp/brett_body").GetComponent <SkinnedMeshRenderer>().enabled = showBody;
            root.transform.Find("geoGrp/brett_hairCards").gameObject.SetActive(showHair);

            // Assign the transforms for the rep
            rigTransforms = BWUtil.GetHumanoidRigTransforms(root);

            // Grab these body parts from the rigTransforms
            head   = rigTransforms.neck.gameObject;
            handL  = rigTransforms.lWrist.gameObject;
            handR  = rigTransforms.rWrist.gameObject;
            pelvis = rigTransforms.spine1.gameObject;

            // Create the nameplate and assign values to the TMP's vars
            namePlate = new GameObject("Nameplate");
            TextMeshPro tm = namePlate.AddComponent <TextMeshPro>();

            tm.text      = name;
            tm.color     = UnityEngine.Color.green;
            tm.alignment = TextAlignmentOptions.Center;
            tm.fontSize  = 1.0f;

            // Prevents the nameplate from being destroyed during a level change
            DontDestroyOnLoad(namePlate);

            MelonCoroutines.Start(AsyncAvatarRoutine(steamId));

            // Gives certain users special appearances
            Extras.SpecialUsers.GiveUniqueAppearances(steamId, realRoot, tm);

            // Change the shader to the one that's already used in the game
            // Without this, the player model will only show in one eye
            foreach (SkinnedMeshRenderer smr in ford.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                foreach (Material m in smr.sharedMaterials)
                {
                    m.shader = Shader.Find("Valve/vr_standard");
                }
            }
            foreach (MeshRenderer smr in ford.GetComponentsInChildren <MeshRenderer>())
            {
                foreach (Material m in smr.sharedMaterials)
                {
                    m.shader = Shader.Find("Valve/vr_standard");
                }
            }

#if DEBUG
            zCubed.Accessories.Accessory.CreateDummies(realRoot.parent);
#endif

            this.ford = ford;
        }
Exemplo n.º 17
0
 public User(SteamId steamId)
 {
     SteamId  = steamId;
     ClientId = SteamId;
 }
Exemplo n.º 18
0
 internal Lobby(SteamId id)
 {
     Id = id;
 }
Exemplo n.º 19
0
        protected override void OnNewConnectionInternal(SteamId id)
        {
            Debug.Log("OnNewConnectionInternal in server");

            SteamNetworking.AcceptP2PSessionWithUser(id);
        }
Exemplo n.º 20
0
        protected override void OnConnectionFailed(SteamId remoteId)
        {
            int connectionId = steamToMirrorIds.TryGetValue(remoteId, out int connId) ? connId : nextConnectionID++;

            OnDisconnected.Invoke(connectionId);
        }
Exemplo n.º 21
0
 public Stat(string name)
 {
     Name   = name;
     UserId = 0;
 }
Exemplo n.º 22
0
 public Query WhereUserVotedDown(SteamId user = default)
 {
     userType = UserUGCList.VotedDown; LimitUser(user); return(this);
 }
Exemplo n.º 23
0
 public Stat(string name, SteamId user)
 {
     Name   = name;
     UserId = user;
 }
Exemplo n.º 24
0
 public Query WhereUserSubscribed(SteamId user = default)
 {
     userType = UserUGCList.Subscribed; LimitUser(user); return(this);
 }
Exemplo n.º 25
0
 public override int GetHashCode()
 {
     return(Address.GetHashCode() + SteamId.GetHashCode() + ConnectionPort.GetHashCode() + QueryPort.GetHashCode());
 }
Exemplo n.º 26
0
 public Query WhereUserFollowed(SteamId user = default)
 {
     userType = UserUGCList.Followed; LimitUser(user); return(this);
 }
Exemplo n.º 27
0
 public FacepunchNetworkingPlayer(uint networkId, SteamId steamId, bool isHost, NetWorker networker) : base(networkId, "", isHost, null, networker)
 {
     PacketManager = new UDPPacketManager();
     SteamID       = steamId;
 }
Exemplo n.º 28
0
        public override bool Equals(object obj)
        {
            var item = obj as Player;

            return(item != null && SteamId.Equals(item.SteamId));
        }
Exemplo n.º 29
0
 internal User(SteamNetworkClient client, SteamId id, FriendRelationship relationship) : base(client)
 {
     _steamId      = id;
     _relationship = relationship;
 }
Exemplo n.º 30
0
 protected override void OnConnectionFailed(SteamId remoteId) => OnDisconnected.Invoke();
Exemplo n.º 31
0
        public void InvalidSteam2Id(uint id, AccountType type, Universe universe, uint instance)
        {
            var value = new SteamId(id, type, universe, instance);

            Assert.Throws <ArgumentException>(() => SteamId.ToSteam2(value));
        }