mirror of
https://github.com/SteamAutoCracks/DepotDownloaderMod.git
synced 2026-02-11 04:10:56 +01:00
Implement friend (un)blocking. Closes #29.
This commit is contained in:
@@ -270,3 +270,18 @@ class MsgClientGetNumberOfCurrentPlayersResponse<EMsg::ClientGetNumberOfCurrentP
|
||||
EResult result;
|
||||
uint numPlayers;
|
||||
};
|
||||
|
||||
class MsgClientSetIgnoreFriend<EMsg::ClientSetIgnoreFriend>
|
||||
{
|
||||
steamidmarshal ulong mySteamId;
|
||||
steaidmarshal ulong steamIdFriend;
|
||||
|
||||
byte ignore;
|
||||
};
|
||||
|
||||
class MsgClientSetIgnoreFriendResponse<EMsg::ClientSetIgnoreFriendResponse>
|
||||
{
|
||||
ulong unknown;
|
||||
|
||||
EResult result;
|
||||
};
|
||||
@@ -1804,5 +1804,77 @@ namespace SteamKit2.Internal
|
||||
}
|
||||
}
|
||||
|
||||
public class MsgClientSetIgnoreFriend : ISteamSerializableMessage
|
||||
{
|
||||
public EMsg GetEMsg() { return EMsg.ClientSetIgnoreFriend; }
|
||||
|
||||
// Static size: 8
|
||||
private ulong mySteamId;
|
||||
public SteamID MySteamId { get { return new SteamID( mySteamId ); } set { mySteamId = value.ConvertToUInt64(); } }
|
||||
// Static size: 8
|
||||
public ulong SteamIdFriend { get; set; }
|
||||
// Static size: 1
|
||||
public byte Ignore { get; set; }
|
||||
|
||||
public MsgClientSetIgnoreFriend()
|
||||
{
|
||||
mySteamId = 0;
|
||||
SteamIdFriend = 0;
|
||||
Ignore = 0;
|
||||
}
|
||||
|
||||
public void Serialize(Stream stream)
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter( stream );
|
||||
|
||||
bw.Write( mySteamId );
|
||||
bw.Write( SteamIdFriend );
|
||||
bw.Write( Ignore );
|
||||
|
||||
}
|
||||
|
||||
public void Deserialize( Stream stream )
|
||||
{
|
||||
BinaryReader br = new BinaryReader( stream );
|
||||
|
||||
mySteamId = br.ReadUInt64();
|
||||
SteamIdFriend = br.ReadUInt64();
|
||||
Ignore = br.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
public class MsgClientSetIgnoreFriendResponse : ISteamSerializableMessage
|
||||
{
|
||||
public EMsg GetEMsg() { return EMsg.ClientSetIgnoreFriendResponse; }
|
||||
|
||||
// Static size: 8
|
||||
public ulong Unknown { get; set; }
|
||||
// Static size: 4
|
||||
public EResult Result { get; set; }
|
||||
|
||||
public MsgClientSetIgnoreFriendResponse()
|
||||
{
|
||||
Unknown = 0;
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
public void Serialize(Stream stream)
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter( stream );
|
||||
|
||||
bw.Write( Unknown );
|
||||
bw.Write( (int)Result );
|
||||
|
||||
}
|
||||
|
||||
public void Deserialize( Stream stream )
|
||||
{
|
||||
BinaryReader br = new BinaryReader( stream );
|
||||
|
||||
Unknown = br.ReadUInt64();
|
||||
Result = (EResult)br.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
||||
@@ -590,5 +590,27 @@ namespace SteamKit2
|
||||
this.GameID = invite.game_id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This callback is fired in response to an attempt at ignoring a friend.
|
||||
/// </summary>
|
||||
public sealed class IgnoreFriendCallback : CallbackMsg
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the result of ignoring a friend.
|
||||
/// </summary>
|
||||
public EResult Result { get; private set; }
|
||||
|
||||
|
||||
#if STATIC_CALLBACKS
|
||||
internal IgnoreFriendCallback( SteamClient client, MsgClientSetIgnoreFriendResponse response )
|
||||
: base( client )
|
||||
#else
|
||||
internal IgnoreFriendCallback( MsgClientSetIgnoreFriendResponse response )
|
||||
#endif
|
||||
{
|
||||
this.Result = response.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,6 +432,27 @@ namespace SteamKit2
|
||||
RequestFriendInfo( new SteamID[] { steamId }, requestedInfo );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignores or unignores a friend on Steam.
|
||||
/// Results are returned in a <see cref="IgnoreFriendCallback"/>.
|
||||
/// </summary>
|
||||
/// <param name="steamId">The SteamID of the friend to ignore or unignore.</param>
|
||||
/// <param name="setIgnore">if set to <c>true</c>, the friend will be ignored; otherwise, they will be unignored.</param>
|
||||
/// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="SteamClient.JobCallback<T>"/>.</returns>
|
||||
public JobID IgnoreFriend( SteamID steamId, bool setIgnore = true )
|
||||
{
|
||||
var ignore = new ClientMsg<MsgClientSetIgnoreFriend>();
|
||||
ignore.SourceJobID = Client.GetNextJobID();
|
||||
|
||||
ignore.Body.MySteamId = Client.SteamID;
|
||||
ignore.Body.Ignore = ( byte )( setIgnore ? 1 : 0 );
|
||||
ignore.Body.SteamIdFriend = steamId;
|
||||
|
||||
this.Client.Send( ignore );
|
||||
|
||||
return ignore.SourceJobID;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles a client message. This should not be called directly.
|
||||
@@ -480,6 +501,10 @@ namespace SteamKit2
|
||||
case EMsg.ClientChatInvite:
|
||||
HandleChatInvite( packetMsg );
|
||||
break;
|
||||
|
||||
case EMsg.ClientSetIgnoreFriendResponse:
|
||||
HandleIgnoreFriendResponse( packetMsg );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,6 +756,20 @@ namespace SteamKit2
|
||||
#else
|
||||
var callback = new ChatInviteCallback( chatInvite.Body );
|
||||
this.Client.PostCallback( callback );
|
||||
#endif
|
||||
}
|
||||
void HandleIgnoreFriendResponse( IPacketMsg packetMsg )
|
||||
{
|
||||
var response = new ClientMsg<MsgClientSetIgnoreFriendResponse>( packetMsg );
|
||||
|
||||
#if STATIC_CALLBACKS
|
||||
var innerCallback = new IgnoreFriendCallback( Client, response.Body );
|
||||
var callback = new SteamClient.JobCallback<IgnoreFriendCallback>( Client, response.TargetJobID, innerCallback );
|
||||
SteamClient.PostCallback( callback );
|
||||
#else
|
||||
var innerCallback = new IgnoreFriendCallback( response.Body );
|
||||
var callback = new SteamClient.JobCallback<IgnoreFriendCallback>( response.TargetJobID, innerCallback );
|
||||
this.Client.PostCallback( callback );
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user