Skip to content

Session 3 : Websockets#5

Open
guillaumeduboc wants to merge 4 commits into
session-3-v2from
session-3-v2-websockets
Open

Session 3 : Websockets#5
guillaumeduboc wants to merge 4 commits into
session-3-v2from
session-3-v2-websockets

Conversation

@guillaumeduboc

Copy link
Copy Markdown
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
Copy Markdown
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

// TODO insert a connection in the DynamoDB
await documentClient
.put({
TableName: 'dojo-serverless-table',

Copy link
Copy Markdown
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

};

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 ;)

// setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id)));
};

const killVirus = async (virusId: string) => {

Copy link
Copy Markdown
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