Skip to content

Delete message socket

Alvin Cheng edited this page Apr 23, 2023 · 2 revisions

Description

This is the delete message socket, this socket will delete a message from the database with the 'server-message-delete' event. As well as telling all devices connected to the server so it could be updated at the same time. This socket will take an 'id' argument for the id for the message, a 'room' argument for the room of the operation, a 'responseToken' argument for the response and finally a 'key' argument for the key. Also as I mentioned before, we are NOT using the default websockets, we are using the socket.io library for web sockets.

What is a response token??

A response token is a token to send a request to if an error occurs.

Example

const io = require("socket.io");

const socket = io("<URL>", { transports: ["websocket"] });

// Send to server
socket.emit("server-message-delete", "<ID>", "<ROOM>", "<TOKEN>", "<KEY>");

socket.on("client-message-delete:room(<ROOM>)", () => {
  /* This will run when a user in the same room types*/
});
Clone this wiki locally