authenticated msgs

This commit is contained in:
ntr 2019-12-24 12:23:33 +10:00
parent 395bf640c9
commit cf4972a1b8
6 changed files with 29 additions and 24 deletions

View File

@ -100,25 +100,23 @@ function Play(args) {
const list = () => {
return (
<div>
<div class='list play'>
<figure>
<button
class="ready"
onClick={() => sendInstancePractice()}>
Tutorial
</button>
<figcaption>Learn MNML</figcaption>
</figure>
<figure>
<button
class='discord-btn'
onClick={() => window.open('https://discord.gg/YJJgurM') }>
&nbsp;
</button>
<figcaption>Join the Community</figcaption>
</figure>
</div>
<div class='list play'>
<figure>
<button
class="ready"
onClick={() => sendInstancePractice()}>
Tutorial
</button>
<figcaption>Learn MNML</figcaption>
</figure>
<figure>
<button
class='discord-btn'
onClick={() => window.open('https://discord.gg/YJJgurM') }>
&nbsp;
</button>
<figcaption>Join the Community</figcaption>
</figure>
</div>
);
};
@ -127,8 +125,9 @@ function Play(args) {
<section class="top">
<div class="news">
<h1>Welcome to MNML</h1>
{news}
{list()}
<hr />
{news}
</div>
<Welcome />
</section>

View File

@ -104,6 +104,10 @@ function registerEvents(store) {
}
function setAccount(account) {
store.dispatch(actions.setAccount(account));
}
function setAuthenticated(account) {
if (account && window.Notification) {
window.Notification.requestPermission();
}
@ -113,6 +117,7 @@ function registerEvents(store) {
}
store.dispatch(actions.setAccount(account));
store.dispatch(actions.setAuthenticated(true));
}
function setEmail(email) {
@ -223,6 +228,7 @@ function registerEvents(store) {
clearTutorial,
clearTutorialGame,
setAccount,
setAuthenticated,
setAccountInstances,
setActiveItem,
setActiveSkill,

View File

@ -270,7 +270,7 @@ function createSocket(events) {
// this object wraps the reply types to a function
const handlers = {
AccountState: onAccount,
AccountAuthenticated: events.setAuthenticated,
AccountAuthenticated: account => events.setAuthenticated(account),
AccountConstructs: onAccountConstructs,
AccountTeam: onAccountTeam,
AccountInstances: onAccountInstances,

View File

@ -44,7 +44,7 @@ use http::{AUTH_CLEAR, TOKEN_HEADER};
#[derive(Debug,Clone,Serialize)]
pub enum RpcMessage {
AccountState(Account),
AccountAuthenticated(()),
AccountAuthenticated(Account),
AccountConstructs(Vec<Construct>),
AccountTeam(Vec<Construct>),
AccountInstances(Vec<Instance>),

View File

@ -50,7 +50,6 @@ impl User for Anonymous {
self.send(RpcMessage::AccountState(self.account.clone()), events, ws)?;
self.send(RpcMessage::StartTutorial(()), events, ws)?;
self.send(RpcMessage::ItemInfo(item_info()), events, ws)?;
Ok(())
}
@ -75,6 +74,7 @@ impl User for Anonymous {
match v {
RpcRequest::Ping {} => return Ok(RpcMessage::Pong(())),
RpcRequest::ItemInfo {} => return Ok(RpcMessage::ItemInfo(item_info())),
RpcRequest::InstancePractice {} =>
Ok(RpcMessage::InstanceState(pg::instance_demo(&self.account)?)),

View File

@ -71,7 +71,7 @@ impl User for Authorised {
info!("authenticated connection account={:?}", self.account);
let a = &self.account;
ws.send(RpcMessage::AccountAuthenticated(()))?;
ws.send(RpcMessage::AccountAuthenticated(a.clone()))?;
// tell events we have connected
events.send(Event::Connect(self.id, a.clone(), ws.clone()))?;