Giter VIP home page Giter VIP logo

hexcore's Introduction

Hexcore

pub package

A Flutter package which provides an interface to the League of Legends Client API (LCU API) and LCU Socket connection.

Usage

Use Hexcore.create to create a new instance of Hexcore

Hexcore hexcore = await Hexcore.create();

await hexcore.connectToClient();

At the moment that Hexcore connect to the client, it will watch the League Client state. If the player closes the client, the package will wait until the player reopen it.

Hexcore has three states:

  1. initial: When the instance of Hexcore is created.
  2. searchingClientPath: When Hexcore is searching for the League Client path at the player's PC.
  3. waiting: Hexcore already found the League Client Path, and now is waiting for the player to open the game or trying to connect to it.
  4. connected: Hexcore is connected and ready to go.

Hexcore has a ValueNotifier that notifies about the state of the connection, so you can use an AnimatedContainer to build according to it's state.

...
AnimatedBuilder(
    animation: hexcore.status,
    builder: (BuildContext context, Widget? child) {
        if (hexcore.status.value == HexcoreStatus.waiting) {
            return const Center(
                child: CircularProgressIndicator(),
            );
        } else {
            return const Center(
                child: Text('Hexcore is ready!');
            );
        }
    },
);
...

Send custom notification

With hexcore you can send notification throw the League Client.

await hexcore.sendCustomNotification(
    title: 'Hexcore notification',
    details: 'Hello World',
    iconUrl: 'https://some_url_here',
    backgroundUrl: 'https://some_url_here',
);

Create and join a custom lobby

This method create and insert the current player in a custom lobby.

await hexcore.createCustomMatch(
    lobbyName: 'Custom game #1',
    lobbyPassword: 'hexcore_123', 
);

List custom lobbys

List all the available custom matches, so you can get the information you need to join a match.

List<Map<String,dynamic>> matches = await hexcore.listCustomMatches();

Join custom match

Use this method when you need to join a match. You can get the id of the match at listCustomMatches method.

await hexcore.joinCustomMatch(
    id: 'lobby_id',
    password: 'lobby_password'
);

HexcoreSocket Usage

In this package you can also find an interface for the LCU Socket connection, where you can subscribe and listen to events emitted by LCU.

Create an instance and use HexcoreSocket.connect to connect.

โ— You need to connect to the LCU using Hexcore.connectToClient before trying the socket connection. โ—

HexcoreSocket hexcoreSocket = HexcoreSocket();

await hexcoreSocket.connect();

Subscribing to LCU Events.

To subscribe to new events you need to call the method add.

hexcoreSocket.add('[5, "OnJsonApiEvent"]');

In this example you subscribe to all LCU Events. Here you can understand more about LCU Events.

Handling Events

Use listen method to create a StreamSubscription to handle the events that has been subscribed.

hexcoreSocket.listen((event){
    print(event);
});

Additional information

You may need to override the badCertificateCallback in way to send requests to the League Client, there is a example:

HttpOverrides.global = MyHttpOverrides();

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.