Collaboration: Room chat

# feat
- chatting antar user
- lihat info grup
## No issue
This commit is contained in:
2024-04-29 10:30:59 +08:00
parent 2929459e95
commit 2a4d2951af
25 changed files with 366 additions and 162 deletions

View File

@@ -1,10 +1,10 @@
import mqtt from "mqtt";
// declare global {
// var mqtt_client: mqtt.MqttClient;
// }
declare global {
var mqtt_client: mqtt.MqttClient;
}
// const mqtt_client =
// globalThis.mqtt_client || mqtt.connect("wss://io.wibudev.com");
const mqtt_client =
globalThis.mqtt_client || mqtt.connect("wss://io.wibudev.com");
// export default mqtt_client;
export default mqtt_client;

View File

@@ -1,22 +1,20 @@
"use client";
import { useEffect } from "react";
// import mqtt_client from "./mqtt_client";
// import { useAtom } from "jotai";
// import { gs_coba_chat } from "@/app/makuro/gs_coba";
import { useEffect, useState } from "react";
import mqtt_client from "./mqtt_client";
import { useAtom } from "jotai";
import { gs_coba_chat } from "@/app/makuro/gs_coba";
// export default function MqttLoader() {
// const [msg, setMsg] = useAtom(gs_coba_chat);
// useEffect(() => {
// mqtt_client.on("connect", () => {
// console.log("connected");
// mqtt_client.subscribe("example_hipmi");
// });
export default function MqttLoader() {
useEffect(() => {
mqtt_client.on("connect", () => {
console.log("connected");
// mqtt_client.subscribe("server12");
});
// mqtt_client.on("message", (apa, message) => {
// console.log(message.toLocaleString());
// setMsg(message.toLocaleString() as any);
// });
// }, [setMsg]);
// return null;
// }
// mqtt_client.on("message", (apa) => {
// console.log("Ini yang di utils");
// });
}, []);
return null;
}