diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index 17d9aeeb..fe5dd570 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -12,7 +12,7 @@ // "player "; } -.game .team { +.game .team, .faceoff .team { display: grid; grid-template-columns: repeat(3, 1fr); diff --git a/client/src/events.jsx b/client/src/events.jsx index 0cc1e4a0..5515ddba 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -12,6 +12,13 @@ const { tutorialVbox } = require('./tutorial.utils'); function registerEvents(store) { function notify(msg) { + if (Notification && Notification.permission === 'granted') { + const n = new Notification('MNML', { + body: msg, + tag: 'MNML', + }); + } + return infoToast(msg); } @@ -130,6 +137,10 @@ function registerEvents(store) { if (account) { LogRocket.init('yh0dy3/mnml'); LogRocket.identify(account.id, account); + + if (Notification) { + Notification.requestPermission(); + } } store.dispatch(actions.setAccount(account)); diff --git a/client/src/socket.jsx b/client/src/socket.jsx index 85d81154..340310b8 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -264,13 +264,14 @@ function createSocket(events) { Pong: onPong, Demo: onDemo, - QueueRequested: () => events.notify('pvp queue request received'), - QueueJoined: () => events.notify('you have joined the pvp queue'), - InviteRequested: () => events.notify('pvp invite request received'), + QueueRequested: () => events.notify('PVP queue request received.'), + QueueJoined: () => events.notify('You have joined the PVP queue.'), + QueueFound: () => events.notify('Your PVP game has started.'), + InviteRequested: () => events.notify('PVP invite request received.'), Invite: code => events.setInvite(code), InstanceChat: chat => events.setInstanceChat(chat), ChatWheel: wheel => events.setChatWheel(wheel), - Joining: () => events.notify('searching for instance...'), + // Joining: () => events.notify('Searching for instance...'), Processing: () => true, Error: errHandler, diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 54602215..29d89d34 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -65,6 +65,7 @@ pub enum RpcMessage { QueueRequested(()), QueueJoined(()), QueueCancelled(()), + QueueFound(()), InviteRequested(()), Invite(String), diff --git a/server/src/warden.rs b/server/src/warden.rs index 38779346..ff4b2760 100644 --- a/server/src/warden.rs +++ b/server/src/warden.rs @@ -112,6 +112,10 @@ impl Warden { pair.0.tx.send(msg.clone())?; pair.1.tx.send(msg)?; + // send msgs for browser notifications + pair.0.tx.send(RpcMessage::QueueFound(()))?; + pair.1.tx.send(RpcMessage::QueueFound(()))?; + Ok(()) } }