Skip to content

Flourite423/Talkbox-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Talkbox Server

一个基于 C++ 的聊天服务器,支持实时消息传递、论坛功能和文件共享。

目录

技术栈

  • 编程语言: C++17
  • 数据库: SQLite3
  • 网络协议: HTTP/1.1
  • 数据格式: JSON
  • 构建工具: Make
  • 线程库: pthread

快速开始

环境要求

  • Linux 操作系统
  • GCC 7.0+ (支持 C++17)
  • SQLite3 开发库
  • pthread 库

安装依赖

Ubuntu/Debian:

sudo apt update
sudo apt install build-essential libsqlite3-dev

Arch Linux:

sudo pacman -S base-devel sqlite

编译运行

  1. 克隆项目
git clone https://github.com/Flourite423/Talkbox-server.git
cd Talkbox-server
  1. 编译项目
make
  1. 启动服务器
# 使用默认端口 8080
./scripts/start.sh

# 或指定端口
./scripts/start.sh 9000
  1. 测试服务器
# 运行测试脚本
./scripts/test.sh

API 文档

详细的 API 接口文档请查看 API.md

主要接口概览

  • POST /api/register - 用户注册
  • POST /api/login - 用户登录
  • POST /api/logout - 用户登出
  • GET /api/messages - 获取消息列表
  • POST /api/messages - 发送消息
  • GET /api/forums - 获取论坛帖子
  • POST /api/forums - 发布帖子
  • POST /api/upload - 上传文件
  • GET /api/download - 下载文件

请求示例

# 用户注册
curl -X POST http://localhost:8080/api/register \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "password": "123456"}'

# 用户登录
curl -X POST http://localhost:8080/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "password": "123456"}'

项目结构

Talkbox-server/
├── src/                    # 源代码目录
│   ├── main.cpp           # 程序入口
│   ├── server.cpp/h       # 服务器核心
│   ├── database.cpp/h     # 数据库操作
│   ├── user_manager.cpp/h # 用户管理
│   ├── message_service.cpp/h # 消息服务
│   ├── forum_service.cpp/h   # 论坛服务
│   ├── file_manager.cpp/h    # 文件管理
│   └── common.cpp/h       # 通用工具
├── build/                 # 编译输出目录
├── scripts/               # 脚本目录
│   ├── start.sh          # 启动脚本
│   └── test.sh           # 测试脚本
├── uploads/               # 文件上传目录
├── Makefile              # 构建配置
├── API.md                # API 文档
├── README.md             # 项目说明
└── LICENSE               # 许可证

构建说明

# 编译项目
make

# 清理构建文件
make clean

# 安装到系统 (需要 root 权限)
sudo make install

# 卸载
sudo make uninstall

许可证

详细信息请查看 LICENSE 文件。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published