Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send additional data to Chobby to be independent from steam overlay #2433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ChobbyLauncher/ChobbyLoopbackMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ public class DownloadFileProgress
[ChobbyMessage]
public class SteamOnline
{

public string AuthToken { get; set; }
public List<string> Friends { get; set; }
public List<SteamFriend> Friends { get; set; }
public string FriendSteamID { get; set; }
public string SuggestedName { get; set; }
public List<ulong> Dlc { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions ChobbyLauncher/ChobbylaLocalListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using PlasmaDownloader;
using PlasmaShared;
using ZkData;
using static ChobbyLauncher.SteamOnline;
using Timer = System.Threading.Timer;

namespace ChobbyLauncher
Expand Down Expand Up @@ -756,13 +757,13 @@ private async Task SendSteamOnline()
{
var friendId = initialConnectLobbyID != 0 ? steam.GetLobbyOwner(initialConnectLobbyID) : null;



await
SendCommand(new SteamOnline()
{
AuthToken = steam.AuthToken,
Friends = steam.Friends.Select(x => x.ToString()).ToList(),
Friends = steam.Friends,
FriendSteamID = friendId?.ToString(),
SuggestedName = steam.MySteamNameSanitized,
Dlc = steam.GetDlcList()
Expand Down
36 changes: 28 additions & 8 deletions ChobbyLauncher/SteamClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public enum OverlayOption

public string AuthToken { get; private set; }

public List<ulong> Friends { get; private set; }
public List<SteamFriend> Friends { get; private set; }
public bool IsOnline { get; private set; }
public ChobbylaLocalListener Listener { get; set; }

Expand Down Expand Up @@ -85,7 +85,7 @@ public void ConnectToSteam()
public ulong? GetLobbyOwner(ulong lobbyID)
{
if (IsOnline)
foreach (var f in GetFriends())
foreach (var f in GetFriendIDs())
{
FriendGameInfo_t gi;
SteamFriends.GetFriendGamePlayed(new CSteamID(f), out gi);
Expand Down Expand Up @@ -155,7 +155,7 @@ public void PrepareToHostP2PGame(SteamHostGameRequest request)
ulong.TryParse(player.SteamID, out playerSteamID);

p2pProxies[playerSteamID] = null;
SendSteamMessage(playerSteamID, new SteamP2PRequestPrepareProxy() {Channel = steamChannelCounter++});
SendSteamMessage(playerSteamID, new SteamP2PRequestPrepareProxy() { Channel = steamChannelCounter++ });
}

// wait for response
Expand Down Expand Up @@ -191,7 +191,7 @@ public void PrepareToHostP2PGame(SteamHostGameRequest request)
ScriptPassword = player.ScriptPassword
});
}

// send command to start spring to self
Listener.SendCommand(new SteamHostGameSuccess() { HostPort = gameHostUdpPort });
});
Expand Down Expand Up @@ -241,7 +241,20 @@ private string GetClientAuthTokenHex()
}


private List<ulong> GetFriends()
private List<SteamFriend> getFriends()
{
if (IsOnline)
{
return GetFriendIDs().Select(x => new SteamFriend()
{
Name = SteamFriends.GetFriendPersonaName(x),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add avatar

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But avatar would have to be downloaded to an image file in the lobby?! Is it worth doing this for all your steam friends?

SteamID = x.ToString()
}).ToList();
}
return null;
}

private List<ulong> GetFriendIDs()
{
if (IsOnline)
{
Expand Down Expand Up @@ -274,7 +287,7 @@ private void OnSteamOnline()
newConnectionCallback = Callback<P2PSessionRequest_t>.Create(t => SteamNetworking.AcceptP2PSessionWithUser(t.m_steamIDRemote));
MySteamNameSanitized = Utils.StripInvalidLobbyNameChars(GetMyName());


var ev = new EventWaitHandle(false, EventResetMode.ManualReset);
AuthToken = GetClientAuthTokenHex();
CreateLobbyAsync((lobbyID) =>
Expand All @@ -283,7 +296,7 @@ private void OnSteamOnline()
ev.Set();
});
SteamNetworking.AllowP2PPacketRelay(true);
Friends = GetFriends();
Friends = GetFriendIDs();
ev.WaitOne(2000);
SteamOnline?.Invoke();
}
Expand Down Expand Up @@ -323,7 +336,7 @@ private void DisposeExistingProxies()
/// </summary>
private void ProcessMessage(ulong remoteUser, SteamP2PConfirmCreateProxy cmd)
{
p2pProxies[remoteUser] = new SteamP2PPortProxy(cmd.Channel, new CSteamID(remoteUser), gameHostUdpPort);
p2pProxies[remoteUser] = new SteamP2PPortProxy(cmd.Channel, new CSteamID(remoteUser), gameHostUdpPort);
}

/// <summary>
Expand Down Expand Up @@ -425,4 +438,11 @@ private void TimerOnElapsed(object sender)
}
}
}

class SteamFriend
{

public string SteamID;
public string Name;
}
}