aboutsummaryrefslogtreecommitdiff
path: root/src/Chat.js
diff options
context:
space:
mode:
authorLibravatar Renard 2020-03-12 01:08:32 -0300
committerLibravatar Renard 2020-03-12 01:08:32 -0300
commit4c109a9bb8c9a158b3d2f18f3216ce95d52e2ae8 (patch)
tree10fb6f7ee225d657ae1372c89276d575666990f3 /src/Chat.js
parent4f073c7e5c0df8e8a3ac3c474b07bf2a8f1a0a2f (diff)
downloadbairadio-app-4c109a9bb8c9a158b3d2f18f3216ce95d52e2ae8.tar.gz
bairadio-app-4c109a9bb8c9a158b3d2f18f3216ce95d52e2ae8.tar.xz
bairadio-app-4c109a9bb8c9a158b3d2f18f3216ce95d52e2ae8.zip
Implementación de historial de chat
Diffstat (limited to 'src/Chat.js')
-rw-r--r--src/Chat.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/Chat.js b/src/Chat.js
index 4117183..701d0a2 100644
--- a/src/Chat.js
+++ b/src/Chat.js
@@ -39,8 +39,21 @@ class Chat extends Component {
return msg ? msg.replace(/%3A/g, ":") : "";
}
- addMessage(message, stream, own = false, sender = "", color = "grey") {
- var ts = new Date();
+ addMessage(
+ message,
+ stream,
+ own = false,
+ sender = "",
+ color = "grey",
+ timestamp = ""
+ ) {
+ let ts;
+ if (timestamp) {
+ ts = new Date(parseInt(timestamp));
+ console.log(ts);
+ } else {
+ ts = new Date();
+ }
this.setState(
prevState => ({
chat: [
@@ -98,6 +111,17 @@ class Chat extends Component {
case "MSG":
this.addMessage(this.translateColon(args[2]), args[1]);
break;
+ case "HMSG":
+ console.log(line);
+ this.addMessage(
+ this.translateColon(args[3]),
+ args[2],
+ false,
+ "",
+ "grey",
+ args[1]
+ );
+ break;
case "FMSG":
this.addMessage(
this.translateColon(args[3]),
@@ -108,6 +132,7 @@ class Chat extends Component {
break;
case "WELCOME":
this.addMessage("Conectado al chat, " + args[1], "", false, "green");
+ this.client.send("HISTORY:10");
break;
case "COUNT":
this.setState({ chatUserCount: args[1] });
@@ -118,6 +143,11 @@ class Chat extends Component {
"red"
);
break;
+ case "HISTORY_OK":
+ /* Renard: z411: que hago con el HISTORY_OK?
+ Renard: me lo meto en la raja?
+ z411: bien adentro */
+ break;
default:
console.error("[Chat] Unsupported command " + args[0]);
break;