This commit is contained in:
Raven Scott 2024-06-15 03:28:36 -04:00
parent 7350d134a1
commit 5080c37bcf
2 changed files with 128 additions and 8 deletions

120
README.md
View File

@ -10,3 +10,123 @@ To launch the App in Dev Mode:
Lastly - run the app:
`pear dev -s /tmp/tmp_pear`
--------
# LinkUp Documentation
## Overview
LinkUp is a peer-to-peer chat application that allows users to create and join chat rooms, share files, and communicate with each other in real-time. The application uses the Hyperswarm, Hyperdrive, and Corestore libraries for decentralized networking and storage. This documentation provides a comprehensive guide to understanding, setting up, and using LinkUp.
## Table of Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Registering a User](#registering-a-user)
- [Creating a Chat Room](#creating-a-chat-room)
- [Joining a Chat Room](#joining-a-chat-room)
- [Sending Messages](#sending-messages)
- [Attaching Files](#attaching-files)
- [Recording and Sending Audio Messages](#recording-and-sending-audio-messages)
- [Commands](#commands)
- [Development](#development)
- [Project Structure](#project-structure)
- [Event Handling](#event-handling)
- [FAQs](#faqs)
## Configuration
LinkUp uses a configuration file (`config.json`) to store user information, chat room details, and registered users. This file is automatically created and managed by the application.
### Configuration File Structure
```json
{
"userName": "",
"userAvatar": "",
"rooms": [],
"registeredUsers": {}
}
```
- `userName`: The username of the registered user.
- `userAvatar`: The URL of the user's avatar image.
- `rooms`: An array of chat rooms the user has joined or created.
- `registeredUsers`: An object containing registered usernames and their avatar URLs.
## Usage
### Registering a User
1. Launch the application.
2. If the configuration file does not exist, you will be prompted to register.
3. Enter a username and optionally select an avatar image.
4. Submit the registration form to complete the process.
### Creating a Chat Room
1. Click on the "Create/Join Room" button in the sidebar.
2. Click on "Create Room".
3. A new room will be created with a random topic.
### Joining a Chat Room
1. Click on the "Create/Join Room" button in the sidebar.
2. Enter the topic of the room you wish to join in the "Topic" field.
3. Click on "Join Room".
### Sending Messages
1. Select a chat room from the sidebar.
2. Enter your message in the message input box at the bottom of the chat window.
3. Press `Enter` or click on the "Send" button to send the message.
### Attaching Files
1. Click on the "Attach File" button in the message form.
2. Select a file from your device.
3. The file will be uploaded and a download link will be shared in the chat.
### Recording and Sending Audio Messages
1. Click and hold the "Talk" button to start recording an audio message.
2. Release the button to stop recording and send the audio message.
## Commands
LinkUp supports several commands that can be entered in the chat input box:
- `~clear`: Clears the chat messages.
- `~ping`: Responds with "pong".
- `~help`: Lists available commands.
- `~join [topic]`: Joins a chat room with the specified topic.
- `~leave`: Leaves the current chat room.
- `~create [alias]`: Creates a new chat room with the specified alias.
- `~list-files`: Lists all files available in the current chat room.
## Development
### Project Structure
- `app.js`: Main application logic.
- `commands.js`: Command handling logic.
- `index.html`: HTML structure of the application.
- `style.css`: CSS for styling the application.
- `config.json`: Configuration file for storing user and room data.
### Event Handling
LinkUp uses an `EventEmitter` to handle various events such as receiving messages, joining rooms, and updating the peer count. Event listeners are set up during the initialization process.
### Key Functions
- `initialize()`: Initializes the application, sets up event listeners, and loads configuration.
- `registerUser()`: Handles user registration.
- `createChatRoom()`: Creates a new chat room.
- `joinChatRoom()`: Joins an existing chat room.
- `sendMessage()`: Sends a text message.
- `handleFileInput()`: Handles file attachments.
- `setupEventListeners()`: Sets up event listeners for UI interactions.
## FAQs
**Q: How do I change my username or avatar?**
A: Currently, changing username or avatar after registration is not supported. You would need to delete the `config.json` file and restart the application to re-register.
**Q: How can I see the list of files shared in a room?**
A: Use the `~list-files` command to see all files shared in the current chat room.
**Q: How do I leave a chat room?**
A: Click on the "Leave Room" button in the chat window.
For more information, please refer to the [Pears Documentation](https://docs.pears.com/).
Feel free to contribute to this project by submitting issues or pull requests on [Git](https://git.ssh.surf/snxraven/LinkUp-P2P-Chat).

View File

@ -7,4 +7,4 @@ export default {
// Send the audio message using the bot instance
bot.sendAudioMessage(audioFilePath, audioType);
}
};
};