Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Visual update, use ekko nuget package, fix linux support.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xInception committed Feb 9, 2023
1 parent 74a880b commit 89c7743
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 31 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified LobbyReveal.sln
100644 → 100755
Empty file.
7 changes: 5 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# LobbyReveal
#### LobbyReveal is a small app that lets you see who is in your lobby.
## Example
![image](https://cdn.discordapp.com/attachments/882326156613910528/1042791430059475005/image.png)
![image](https://cdn.discordapp.com/attachments/881887652155117621/1073273537122549891/image.png)
![image](https://cdn.discordapp.com/attachments/881887652155117621/1073273708132708403/image.png)
## Where can i download the compiled version?
Head over to [releases](https://github.com/Riotphobia/LobbyReveal/releases/)
## How can i compile it for myself?
* .NET Framework 4.8 which only works for windows
* .NET 7.0 which works for windows, macos and linux!
* .NET 6.0 which works for windows, macos and linux!
##### You will need to install git (or just download the files from github).
##### You will need to install visual studio and the SDK for the runtime you want to use.
##### Open a command line, use `git clone https://github.com/Riotphobia/LobbyReveal` (or manually download it) and then cd into the folder.Run `dotnet build`. The files should be inside of `\src\LobbyReveal\bin\Debug\`
## What is Ekko?
* My LCU project, open sourced too. [EKKO](https://github.com/0xInception/Ekko)
54 changes: 30 additions & 24 deletions src/LobbyReveal/LobbyHandler.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum Platform
JP1
}
public delegate void OnUpdate(LobbyHandler handler, string[] names);

public class LobbyHandler
{
private readonly LeagueApi _api;
Expand All @@ -50,8 +51,9 @@ public LobbyHandler(LeagueApi api)
_api = api;
_cache = Array.Empty<string>();
}
public OnUpdate OnUpdate;
public EventHandler OnError;

public OnUpdate OnUpdate;
public EventHandler OnError;


public void Start()
Expand All @@ -71,14 +73,16 @@ public string[] GetSummoners()
{
return _region;
}

private async Task Loop()
{
while (true)
{
Thread.Sleep(2000);
if (_region is null)

try
{
try
if (_region is null)
{
var z = await _api.SendAsync(HttpMethod.Get, "/rso-auth/v1/authorization/userinfo");
if (string.IsNullOrWhiteSpace(z))
Expand Down Expand Up @@ -106,33 +110,35 @@ private async Task Loop()
{
_region = (Region)region;
}
}

var participants = await _api.SendAsync(HttpMethod.Get, "/chat/v5/participants/champ-select");
if (string.IsNullOrWhiteSpace(participants))
continue;

var participants = await _api.SendAsync(HttpMethod.Get, "/chat/v5/participants/champ-select");
if (string.IsNullOrWhiteSpace(participants))
continue;

var participantsJson = JsonConvert.DeserializeObject<Participants>(participants);
if (participantsJson is null)
continue;
var participantsJson = JsonConvert.DeserializeObject<Participants>(participants);
if (participantsJson?.participants is null)
continue;

var names = participantsJson.participants.Select(x => x.name).ToArray();
var names = participantsJson.participants.Select(x => x.name).ToArray();

if (!_cache.SequenceEqual(names))
{
_cache = names;
OnUpdate?.Invoke(this, names);
}
}
catch(Exception ex)
if (!_cache.SequenceEqual(names))
{
Console.WriteLine(ex.ToString());
OnError?.Invoke(this,EventArgs.Empty);
break;
_cache = names;
OnUpdate?.Invoke(this, names);
}

}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
OnError?.Invoke(this, EventArgs.Empty);
break;
}



}

}

}
2 changes: 1 addition & 1 deletion src/LobbyReveal/LobbyReveal.csproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>disable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<TargetFrameworks>net48;net7.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/LobbyReveal/Participants.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Participant

public class Participants
{
public List<Participant> participants { get; set; }
public List<Participant>? participants { get; set; }
}

public class Userinfo
Expand Down
5 changes: 2 additions & 3 deletions src/LobbyReveal/Program.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async static Task Main(string[] args)
client.ClientAuthInfo.RiotClientPort));
_handlers.Add(handler);
handler.OnUpdate += (lobbyHandler, names) => { _update = true; };
handler.OnError += (sender, eventArgs) => { _handlers.Remove(handler); };
handler.Start();
_update = true;
};
Expand All @@ -52,6 +51,7 @@ public async static Task Main(string[] args)
if (!int.TryParse(input.KeyChar.ToString(), out var i) || i > _handlers.Count || i < 1)
{
Console.WriteLine("Invalid input.");
_update = true;
continue;
}

Expand All @@ -72,7 +72,6 @@ public async static Task Main(string[] args)
{
Process.Start("open", link);
}

_update = true;
}

Expand All @@ -97,7 +96,7 @@ private static void Refresh()
HttpUtility.UrlEncode($"{string.Join(",", _handlers[i].GetSummoners())}");

AnsiConsole.Write(
new Panel(new Text($"{string.Join('\n', _handlers[i].GetSummoners())}\n\n{link}")
new Panel(new Text($"{string.Join("\n", _handlers[i].GetSummoners())}\n\n{link}")
.LeftJustified())
.Expand()
.SquareBorder()
Expand Down

0 comments on commit 89c7743

Please sign in to comment.