Skip to content

Session 3 : Websockets #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: session-3-v2
Choose a base branch
from

Conversation

guillaumeduboc
Copy link
Owner

Tu peux ignorer les changement liés aux alarmes, j'ai oublié de checkout sur une autre branche pour le faire

@guillaumeduboc guillaumeduboc changed the title Session 3 v2 websockets Session 3 : Websockets Oct 25, 2021
@@ -14,18 +15,49 @@ export const createConnection = async (
endpoint: string,
): Promise<void> => {
// TODO insert a connection in the DynamoDB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux enlever ça du coup

@@ -14,18 +15,49 @@ export const createConnection = async (
endpoint: string,
): Promise<void> => {
// TODO insert a connection in the DynamoDB
await documentClient
.put({
TableName: 'dojo-serverless-table',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux mettre ça dans une constante

endpoint,
},
})
.promise();
};

export const deleteConnection = async (connectionId: string): Promise<void> => {
// TODO delete a connection from the DynamoDB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

@@ -7,11 +7,38 @@ import { Item } from '@libs/types';
import { Virus } from '../virus/types';

const sendMessageToEachConnection = async (message: any): Promise<void> => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas une bonne pratique de typer en any

Comment on lines 9 to 17
const sendMessageToEachConnection = async (message: any): Promise<void> => {
// TODO use sendMessageToConnection for each connection
// TODO use sendMessageToConnection for each connection
const connections = await getAllConnections();
await Promise.all(
connections.map(async ({ connectionId, endpoint }): Promise<void> => {
await sendMessageToConnection({ connectionId, endpoint, message });
}),
);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux sortir ça du handler du coup :)

Comment on lines 75 to 82
const addVirus = async () => {
const response = await fetch(
`${process.env.REACT_APP_API_BASE_URL}/virus`,
{ method: 'POST' },
);
const { id } = await response.json();
setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id)));
// const response =
await fetch(`${process.env.REACT_APP_API_BASE_URL}/virus`, {
method: 'POST',
});
// const { id } = await response.json();
// setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id)));
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux faire du ménage ici ;)

method: 'POST',
});
// const { id } = await response.json();
// setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id)));
};

const killVirus = async (virusId: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que tu peux sortir ces fonctions de ta page (et je t'ai déjà fait le retour ;) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants