From 524a30b69d5853878200fa41af55020f76b65f1b Mon Sep 17 00:00:00 2001
From: Renard
Date: Wed, 11 Mar 2020 22:21:29 -0300
Subject: Cambio de protocolo MSG
---
src/App.js | 2 +-
src/Chat.js | 25 ++++++++++++++++++-------
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/App.js b/src/App.js
index 78c8146..d005eed 100644
--- a/src/App.js
+++ b/src/App.js
@@ -333,7 +333,7 @@ class App extends Component {
-
+
diff --git a/src/Chat.js b/src/Chat.js
index 54178f2..7f74a27 100644
--- a/src/Chat.js
+++ b/src/Chat.js
@@ -38,13 +38,20 @@ class Chat extends Component {
return msg ? msg.replace(/%3A/g, ":") : "";
}
- addMessage(message, color, own = false, sender = "") {
+ addMessage(message, stream, own = false, sender = "", color = "grey") {
var ts = new Date();
this.setState(
prevState => ({
chat: [
...prevState.chat,
- { content: message, color: color, own, timestamp: ts, author: sender }
+ {
+ content: message,
+ stream: stream,
+ own,
+ timestamp: ts,
+ author: sender,
+ color: color
+ }
]
}),
() => {
@@ -74,11 +81,13 @@ class Chat extends Component {
sendMessage() {
const { chatMessage } = this.state;
+ const { stream } = this.props;
+ console.log(stream);
if (chatMessage === "") {
return;
}
- this.client.send("MSG:0:" + chatMessage);
- this.addMessage(chatMessage, "black", true);
+ this.client.send(`MSG:${stream.server_name}:${chatMessage}`);
+ this.addMessage(chatMessage, stream.server_name, true, "black");
this.setState({ chatMessage: "" });
}
@@ -86,7 +95,7 @@ class Chat extends Component {
const args = line.split(":");
switch (args[0]) {
case "MSG":
- this.addMessage(this.translateColon(args[2]), this.chatColors[args[1]]);
+ this.addMessage(this.translateColon(args[2]), args[1]);
break;
case "FMSG":
this.addMessage(
@@ -97,7 +106,7 @@ class Chat extends Component {
);
break;
case "WELCOME":
- this.addMessage("Conectado al chat, " + args[1], "green");
+ this.addMessage("Conectado al chat, " + args[1], "", false, "green");
break;
case "COUNT":
this.setState({ chatUserCount: args[1] });
@@ -128,7 +137,9 @@ class Chat extends Component {
[]{" "}
- {message.content}
+ {`${message.stream && "[" + message.stream + "]"} ${
+ message.content
+ }`}
))}
--
cgit v1.2.1-18-gbd029