bryanhitc / lcu-sharp

An API wrapper for the League of Legends client.
MIT License
44 stars 10 forks source link

Fix connection failure when client is initially closed #9

Closed bryanhitc closed 5 years ago

bryanhitc commented 5 years ago

Describe the bug When trying to connect to the league client, the API will wait until the process and lockfile are detected before doing so. This results in successfully parsing the lockfile for the auth token and client port when the client is already open.

However, if the API tries to connect before opening the client, there's a chance that the client hasn't established the web socket server when this API detects both the process and lockfile. This results in an unsuccessful connection to the web socket server, which can only be fixed by instantiating a new ILeagueClientApi after the client is open. This is unacceptable.

To Reproduce Steps to reproduce the behavior:

  1. Make sure the league client is completely closed (no processes running).
  2. Attempt to connect to the client via await LeagueClientApi.ConnectAsync().
  3. Open the client.
  4. You'll either observe event capturing or the lack of it.

The connection to the client's web socket server should complete and be successful before completing the Task, therefore, the latter is not acceptable.

Expected behavior await LeagueClientApi.ConnectAsync() will successfully connect to the client's web socket server before completing.