diff --git a/src/data/Chat.vue b/src/data/Chat.vue new file mode 100644 index 0000000..ec93d63 --- /dev/null +++ b/src/data/Chat.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 4b535dd..7f16cfa 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -4,6 +4,8 @@ import { createLayer } from "game/layers"; import { persistent } from "game/persistence"; import type { PlayerData } from "game/player"; import { computed } from "vue"; +import Chat from "./Chat.vue"; +import { room } from "./socket"; /** * @hidden @@ -18,6 +20,7 @@ export const main = createLayer("main", function (this: BaseLayer) { display: jsx(() => ( <>
placeholder
+ )) }; diff --git a/src/data/socket.tsx b/src/data/socket.tsx index 7f1c2ed..981613b 100644 --- a/src/data/socket.tsx +++ b/src/data/socket.tsx @@ -1,7 +1,7 @@ import Text from "components/fields/Text.vue"; import { jsx, setDefault } from "features/feature"; import { globalBus } from "game/events"; -import settings, { registerSettingField } from "game/settings"; +import { registerSettingField } from "game/settings"; import { io, Socket } from "socket.io-client"; import { load } from "util/save"; import { ref, watch } from "vue"; @@ -136,12 +136,16 @@ function setupSocket(socket: Socket) toast.info(message); globalBus.emit("serverSentInfo"); }); + socket.on("chat", (user, message) => { + globalBus.emit("chat", user, message); + }); socket.on("set rooms", rooms => { globalBus.emit("setRooms", rooms); }); socket.on("joined room", (r, hosting) => { room.value = r; isHosting.value = hosting; + globalBus.emit("chat", undefined, "you joined " + r); }); socket.on("left room", () => { room.value = null; @@ -186,5 +190,6 @@ declare module "game/events" { openMultiplayer: VoidFunction; setRooms: (rooms: ClientRoomData[]) => void; serverSentInfo: VoidFunction; + chat: (user: string | undefined, message: string) => void; } }