@@ -47,7 +47,7 @@ public enum OverlayOption
4747
4848 public string AuthToken { get ; private set ; }
4949
50- public List < ulong > Friends { get ; private set ; }
50+ public List < SteamFriend > Friends { get ; private set ; }
5151 public bool IsOnline { get ; private set ; }
5252 public ChobbylaLocalListener Listener { get ; set ; }
5353
@@ -85,7 +85,7 @@ public void ConnectToSteam()
8585 public ulong ? GetLobbyOwner ( ulong lobbyID )
8686 {
8787 if ( IsOnline )
88- foreach ( var f in GetFriends ( ) )
88+ foreach ( var f in GetFriendIDs ( ) )
8989 {
9090 FriendGameInfo_t gi ;
9191 SteamFriends . GetFriendGamePlayed ( new CSteamID ( f ) , out gi ) ;
@@ -155,7 +155,7 @@ public void PrepareToHostP2PGame(SteamHostGameRequest request)
155155 ulong . TryParse ( player . SteamID , out playerSteamID ) ;
156156
157157 p2pProxies [ playerSteamID ] = null ;
158- SendSteamMessage ( playerSteamID , new SteamP2PRequestPrepareProxy ( ) { Channel = steamChannelCounter ++ } ) ;
158+ SendSteamMessage ( playerSteamID , new SteamP2PRequestPrepareProxy ( ) { Channel = steamChannelCounter ++ } ) ;
159159 }
160160
161161 // wait for response
@@ -191,7 +191,7 @@ public void PrepareToHostP2PGame(SteamHostGameRequest request)
191191 ScriptPassword = player . ScriptPassword
192192 } ) ;
193193 }
194-
194+
195195 // send command to start spring to self
196196 Listener . SendCommand ( new SteamHostGameSuccess ( ) { HostPort = gameHostUdpPort } ) ;
197197 } ) ;
@@ -241,7 +241,20 @@ private string GetClientAuthTokenHex()
241241 }
242242
243243
244- private List < ulong > GetFriends ( )
244+ private List < SteamFriend > getFriends ( )
245+ {
246+ if ( IsOnline )
247+ {
248+ return GetFriendIDs ( ) . Select ( x => new SteamFriend ( )
249+ {
250+ Name = SteamFriends . GetFriendPersonaName ( x ) ,
251+ SteamID = x . ToString ( )
252+ } ) . ToList ( ) ;
253+ }
254+ return null ;
255+ }
256+
257+ private List < ulong > GetFriendIDs ( )
245258 {
246259 if ( IsOnline )
247260 {
@@ -274,7 +287,7 @@ private void OnSteamOnline()
274287 newConnectionCallback = Callback < P2PSessionRequest_t > . Create ( t => SteamNetworking . AcceptP2PSessionWithUser ( t . m_steamIDRemote ) ) ;
275288 MySteamNameSanitized = Utils . StripInvalidLobbyNameChars ( GetMyName ( ) ) ;
276289
277-
290+
278291 var ev = new EventWaitHandle ( false , EventResetMode . ManualReset ) ;
279292 AuthToken = GetClientAuthTokenHex ( ) ;
280293 CreateLobbyAsync ( ( lobbyID ) =>
@@ -283,7 +296,7 @@ private void OnSteamOnline()
283296 ev . Set ( ) ;
284297 } ) ;
285298 SteamNetworking . AllowP2PPacketRelay ( true ) ;
286- Friends = GetFriends ( ) ;
299+ Friends = GetFriendIDs ( ) ;
287300 ev . WaitOne ( 2000 ) ;
288301 SteamOnline ? . Invoke ( ) ;
289302 }
@@ -323,7 +336,7 @@ private void DisposeExistingProxies()
323336 /// </summary>
324337 private void ProcessMessage ( ulong remoteUser , SteamP2PConfirmCreateProxy cmd )
325338 {
326- p2pProxies [ remoteUser ] = new SteamP2PPortProxy ( cmd . Channel , new CSteamID ( remoteUser ) , gameHostUdpPort ) ;
339+ p2pProxies [ remoteUser ] = new SteamP2PPortProxy ( cmd . Channel , new CSteamID ( remoteUser ) , gameHostUdpPort ) ;
327340 }
328341
329342 /// <summary>
@@ -425,4 +438,11 @@ private void TimerOnElapsed(object sender)
425438 }
426439 }
427440 }
441+
442+ class SteamFriend
443+ {
444+
445+ public string SteamID ;
446+ public string Name ;
447+ }
428448}
0 commit comments