-
Notifications
You must be signed in to change notification settings - Fork 0
Connection
dysolix edited this page Apr 8, 2024
·
3 revisions
The connect
function establishes a connection to the LCU using specified options. This function supports various authentication strategies, allowing users to choose the most suitable method for their needs.
public async connect(options?: ConnectionOptions): Promise<void>
-
options
(optional): An object containing connection options. If not provided, default values will be used.
A Promise that resolves when the connection is established successfully, or rejects if an error occurs during the connection process.
The connect
function accepts an object of type ConnectionOptions
to customize the connection process. If omitted, Hasagi will use the Process Authentication Strategy.
-
useWebSocket
(optional): Specifies whether to use the LCU WebSocket for the connection. Events do not work if disabled. Defaults totrue
. -
maxConnectionAttempts
(optional): The maximum number of connection attempts before failing. Defaults to infinite. -
connectionAttemptDelay
(optional): The delay in milliseconds between each (re)connection attempt. Defaults to 5000 milliseconds. -
certificate
(optional): The self-signed Riot Games certificate in string format. Usenull
to disable certificate validation or omit to use the built-in certificate.
The ConnectionOptions
object allows for different authentication strategies, each tailored to specific authentication methods.
- Description: Uses a process for authentication.
- Options: None
-
Example:
{ authenticationStrategy: "process" }
- Description: Uses a lockfile for authentication.
-
Options:
-
lockfile
: Either the lockfile's content or an absolute path to the lockfile (including file name).
-
-
Example:
{ authenticationStrategy: "lockfile", lockfile: "C:/Riot Games/League of Legends/lockfile" }
- Description: Manually provide credentials for authentication.
-
Options:
-
credentials
: An object containing authentication credentials.-
processId
(optional): The process ID. -
port
: The port number. -
password
: The password.
-
-
-
Example:
{ authenticationStrategy: "manual", credentials: { port: 25565, password: "unencoded_password" } }
Hasagi does not automatically reconnect, but can enable it like this.
const client = new HasagiClient();
client.on("disconnected", () => client.connect());
client.connect();