• Home
  • Documentation
  • Guides
  • FAQ
  • Get Llama Chat
Search Results for

    Show / Hide Table of Contents
    • Quickstart
    • Getting Started
    • Integrating into an Existing Project

    How to use Llama Chat in an existing project

    Prerequisites

    Ensure TextMeshPro is in your project already. If it is not, you can add it from the package manager.

    If you do not already have a database, you can use the provided sqlite database in Assets/Llama Software/Llama Chat/Demo/Database/login.db until you move your users to a more production-ready database.

    If you already have a database you will need to make some sql command changes to hook up Llama Chat to your database. If you do not use sqlite please ensure you have the appropriate C# libraries to connect to your database.

    Recommend you add subscribed_channels table as defined in Assets/Llama Software/Llama Chat/Demo/Database/create_login_sample.sql. If you want to support friends list & block list, recommend also having a similar setup for friends table and blocked_players table if you do not already have them.

    Updating SQL to match your database

    I cannot cover all cases in this section, but I will provide the files that interact with a database and the concepts should be similar regardless of platform. This is the primary effort in integrating with an existing project with an existing database.

    Review the sql in Assets/Llama Software/Llama Chat/Demo/Database/create_login_sample.sql so you understand the structure that was implemented for the demo and what kind of query changes need to happen to match your schemas.

    1. Open LlamaSoftware.Chat.SQLitePlayerDatabase class - SQLitePlayerDatabase.cs a. This is the class that primarily interacts with the database i. if you are not using sqlite you will need to connect to your database in a similar fashion to what is done here. ii. If you are using sqlite, find PathToDatabase and update it to whatever URI you have your database on. b. In FindPlayersWhoHaveFriend update the command to match your schema. Currently it uses a unique player identifier and finds all players who have that id in the friend_id column, and joins that with the main account (login) table to be able to generate a Player object. c. In FindFriendsFor update the command to match your schema. Currently it uses a unique player identifier as a key and finds all ids in the friend_id column and joins that with the main account (login) table to be able to generate a Player object d. In FindPlayersWhoAreBlockedBy & FindBlockedPlayersFor the same logic happens, just on the blocked_players table to find which players a given player should not talk to and not be able to be talked to by. e. In FindSubscribedChannelsFor I would recommend just creating this subscribed_channels table and keeping this code the same. f. In DoSavePlayerData it updates a given player's friends, blocked players, and channels.
    2. View LlamaSoftware.Chat.Demo.LoginController - LoginController.cs a. In CreatePlayerFromRow we do Player Construction – you will likely want to do a similar process on successful login. i. If using Mirror, you can abstract the login piece out with an Authenticator.

    Update your Player Prefab

    Add LlamaSoftware.Chat.Player_Chat – Player_Chat.cs to your Player prefab and configure default chat channels.

    In This Article
    Back to top Generated by DocFX