This project is a Node.js wrapper for interacting with a C++ program (llama) using Socket.IO, which allows communication between the server and a Unity client.
Clone the repository to your local machine.
git clone https://github.com/andreykobal/llama-unity-client-server- Node.js
- Unity
- C++ Compiler (e.g., g++)
Navigate to the server directory and install the dependencies.
cd server
npm installRun the server.
npm startYour server will start and listen on port 80.
Server code snippet:
// server.js
import express from 'express';
const app = express();
app.post("/llm-api/message", (req, res) => {
// handling message
});Open your Unity project and import the provided SocketClient script into your project. Attach the SocketClient script to a GameObject.
Unity client code snippet:
// SocketClient.cs
public class SocketClient : MonoBehaviour
{
public void Send()
{
socket.EmitAsync("message", message);
}
}- Start the server by running
npm startin the server directory. - Open your Unity project and play the scene that contains the GameObject with the
SocketClientscript attached. - Enter a message in the input field and click the send button to send a message to the server, which will communicate with the llama C++ program.
The server will process the message and send a response back, which will be displayed in your Unity client.
If you would like to contribute to this project, please fork the repository, make your changes, and submit a pull request.
This project is open-source, and it is licensed under the MIT License.
A huge thanks to everyone who contributed to this project. Your contributions are greatly appreciated.
If you encounter any issues or have questions, please open an issue on GitHub.