Start building the frontend application.
This commit is contained in:
parent
4570923287
commit
2906fbc529
@ -9,12 +9,21 @@
|
|||||||
<script src="/js/chat-service.js"></script>
|
<script src="/js/chat-service.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// start the chat web socket
|
// start the chat web socket
|
||||||
initChatService();
|
|
||||||
|
|
||||||
// render the application
|
// render the application
|
||||||
|
|
||||||
const root = document.body;
|
const root = document.body;
|
||||||
m.render(root, m("h1", "A Stupid Chat"));
|
m.render(root, [
|
||||||
|
m("h1", "A Stupid Chat"),
|
||||||
|
m("div", [
|
||||||
|
m("div", { id: "messages" }, [
|
||||||
|
|
||||||
|
]).
|
||||||
|
m("form", { id: "message-form" }, [
|
||||||
|
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
const ws = initChatService();
|
||||||
|
|
||||||
function initChatService() {
|
function initChatService() {
|
||||||
const ws = new WebSocket("ws://localhost:3000/chat-socket");
|
const ws = new WebSocket("ws://localhost:3000/chat-socket");
|
||||||
|
|
||||||
@ -14,4 +16,6 @@ function initChatService() {
|
|||||||
ws.onerror = function (event) {
|
ws.onerror = function (event) {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return ws;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user