Hi everyone.
Let's continue with the WebSocket.
And in this video let's discuss more about the send and receive the data.
Well right here you can see in order to send an event we will use the emit right.
For example in this case we will create a new emit will be update.
Okay.
And you can see right here this is the argument.
It means we can put every data if you want.
Okay.
For example like item one, item two, item three okay something like that.
You can put many argument as you can.
But right now let's keep the first argument will be the event name in your head, and the rest of that
will be the data right here inside the script.
Let me show you.
I will listen on the update.
Right.
And in here we will get the callback.
Okay.
And inside the callback we will got item one, item two, item three.
And right here I will console.log.
Inside here
Okay.
Now we will send and receive that in the parameter of this callback function over here.
Now you can see I will console.log.
That, it very very cool, right.
Remember that
But with me, I prefer wrap.
All of that inside the object.
Okay.
I prefer using this case for example like product one.
Two
Here will be.
okay, I want to wrap it inside a single object and send that.
Okay, let me remove this thing.
And inside here we will got the message.
Right inside the message.
Right here we can.
Let me console.log.
What is inside the message?
Now you can see it already got the object, we don't need to stringify, right?
Hmm.
Let's continue.
Okay.
You can destructuring over here.
Very easy.
Okay.
And this will be enough.
You can do some logic over here.
And one more thing is the acknowledgement.
Let me show you.
What does it mean?
In the last argument, I can pass the?
The
The callback
Okay.
For example, I will pass the callback with this message over here.
Right here I will call log message.
It means in the second parameter, we can retrieve the callback right inside the callback.
here we can call for example like
Hello.
Okay.
We will call the callback.
And this will trigger this thing
And it will console log on the server.
Let me show you.
I will refresh right here.
It will console log inside the server because on the client we already called callback.
Well in the in the real world application maybe you can write logic for example, like something like
that.
Will call the callback to trigger something in the server.
Right.
So that's for the video.
It very easy right.
I will see you in the next.