Skip to content

Commit

Permalink
Merge pull request #41 from SalesianosZaragoza/dev_JMK
Browse files Browse the repository at this point in the history
Closes #29
  • Loading branch information
jesusmonteroking committed Mar 8, 2024
2 parents 3756580 + 347a9c6 commit 3b20e20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion echo-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys

HOST = "127.0.0.1"
PORT = 65437
PORT = 65438

console = Console()
style = Style.from_dict(
Expand Down
23 changes: 21 additions & 2 deletions echo-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

HOST = "127.0.0.1"
PORT = 65437
PORT = 65438
TIEMPO_ESPERA = 100 # segundos

# Diccionario para almacenar los canales y usuarios
Expand Down Expand Up @@ -172,7 +172,26 @@ def send_message(conn, input_client, username):


def send_whisper(conn, input_client, username):
pass
global users
parts = input_client.split(" ", 2)
if len(parts) < 3:
conn.sendall("Formato incorrecto. Usa /WHISPER [nombreUsuario] [mensaje]".encode("utf-8"))
return

recipient_username = parts[1]
message_to_send = parts[2]

if recipient_username in users:
recipient_conn = users[recipient_username]["conn"]
try:
recipient_conn.sendall(
f"{username} te susurró: {message_to_send}".encode("utf-8")
)
except Exception as e:
print(f"Error al enviar mensaje a {recipient_username}: {e}")
conn.sendall(f"No se pudo enviar el mensaje a {recipient_username}.".encode("utf-8"))
else:
conn.sendall(f"El usuario {recipient_username} no está disponible o no está registrado.".encode("utf-8"))


def broadcast_message(conn, input_client, username):
Expand Down

0 comments on commit 3b20e20

Please sign in to comment.