Add README.md with project overview and setup instructions
This commit is contained in:
commit
21922a11df
|
|
@ -0,0 +1,91 @@
|
||||||
|
# PSP Chat – Servidor TCP con interfaz web tipo Telegram
|
||||||
|
|
||||||
|
## Arquitectura
|
||||||
|
|
||||||
|
```
|
||||||
|
[Navegador A] ──WebSocket──► [client_web.py] ──TCP──►
|
||||||
|
[server.py :9000]
|
||||||
|
[Navegador B] ──WebSocket──► [client_web.py] ──TCP──►
|
||||||
|
```
|
||||||
|
|
||||||
|
- **server.py** — Servidor TCP puro con threading. Gestiona usuarios, salas, mensajes.
|
||||||
|
- **client_web.py** — Puente Flask + Socket.IO entre navegadores y el servidor TCP.
|
||||||
|
|
||||||
|
## Inicio rápido (todo en local)
|
||||||
|
|
||||||
|
### Paso 1 – Instalar dependencias
|
||||||
|
```bash
|
||||||
|
pip install flask flask-socketio eventlet
|
||||||
|
```
|
||||||
|
|
||||||
|
### Paso 2 – Arrancar el servidor TCP
|
||||||
|
```bash
|
||||||
|
python server.py
|
||||||
|
# Escucha en 0.0.0.0:9000
|
||||||
|
```
|
||||||
|
|
||||||
|
### Paso 3 – Arrancar el cliente web (otro terminal)
|
||||||
|
```bash
|
||||||
|
python client_web.py
|
||||||
|
# Interfaz web en http://localhost:5001
|
||||||
|
```
|
||||||
|
|
||||||
|
### Paso 4 – Abrir varios navegadores
|
||||||
|
```
|
||||||
|
http://localhost:5001
|
||||||
|
```
|
||||||
|
Cada pestaña/dispositivo puede conectarse con un nick diferente.
|
||||||
|
|
||||||
|
## Uso en red local (varios equipos)
|
||||||
|
|
||||||
|
**En el servidor** (IP ej: 192.168.1.10):
|
||||||
|
```bash
|
||||||
|
python server.py
|
||||||
|
python client_web.py --server 192.168.1.10
|
||||||
|
```
|
||||||
|
|
||||||
|
**Desde otros equipos**: abrir `http://192.168.1.10:5001`
|
||||||
|
|
||||||
|
## Opciones del cliente web
|
||||||
|
```
|
||||||
|
python client_web.py --server <IP> # IP del servidor TCP (default: 127.0.0.1)
|
||||||
|
--port <9000> # Puerto TCP (default: 9000)
|
||||||
|
--web-port <5001> # Puerto web (default: 5001)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Protocolo TCP (JSON por líneas)
|
||||||
|
|
||||||
|
El servidor habla JSON terminado en `\n`. Puedes conectarte con `netcat` o cualquier cliente TCP:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nc localhost 9000
|
||||||
|
{"type":"join","nick":"Test"}
|
||||||
|
{"type":"msg","room":"general","text":"Hola!"}
|
||||||
|
{"type":"pm","to":"Alice","text":"mensaje privado"}
|
||||||
|
{"type":"create","room":"mi_sala"}
|
||||||
|
{"type":"join_room","room":"mi_sala"}
|
||||||
|
{"type":"leave_room","room":"mi_sala"}
|
||||||
|
{"type":"users"}
|
||||||
|
{"type":"rooms"}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Características
|
||||||
|
|
||||||
|
- 🌐 Sala **#general** siempre disponible
|
||||||
|
- 📁 Crear salas personalizadas
|
||||||
|
- 📩 Mensajes **privados** (PM) entre usuarios
|
||||||
|
- 👥 Lista de usuarios en línea en tiempo real
|
||||||
|
- 🚪 Unirse y salir de salas
|
||||||
|
- 🌙 Tema oscuro estilo Telegram
|
||||||
|
- 🔔 Notificaciones de mensajes no leídos
|
||||||
|
- 📱 Responsive para móvil
|
||||||
|
|
||||||
|
## Estructura
|
||||||
|
```
|
||||||
|
chatapp/
|
||||||
|
├── server.py # Servidor TCP puro
|
||||||
|
├── client_web.py # Puente Flask + Socket.IO
|
||||||
|
├── requirements.txt
|
||||||
|
└── templates/
|
||||||
|
└── index.html # UI Telegram-like
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue