Hi everyone.
Let's continue with a friend.
Gateway.
Okay, right now we already got the save friend.
We need to convert it into the zero again with exactly the same structure.
Okay, so for that reason, this guy, if you remember in here, we already got the populate with the
sender okay.
And we also populate with the receivers right.
So right right now we need to populate that also right after we already got the save friend we can create
the method for get that.
Let me create that as in.
Find one.
And right here I will call friend equal.
Why not friend request model not file by right here and make sure we populate us.
With listed and we need to give no frame.
I will.
Throw new not file etc. right?
No file.
Friend request.
No file.
Okay.
And return of right over here.
And now, after we already have a frame, we need to.
Write, friend.
Request.
Okay.
That's what this friend request.
Right.
Equal away this dot not.
Buy one and boost the idea over here.
Alright, after we already got the friend request we need to send, right?
Now we need to inject the friend gateway.
And now I will call the handles.
Send friend request.
Okay.
Let us.
And, uh.
What?
We need both.
We need to convert this thing into the digital.
Right.
We already created utility methods, right?
We released the water over here.
Let me create this method.
Here you say right here we got the response blackboard over here.
And what we need to ago.
We need to emit events with the same friend request.
Put the data over here.
Okay, now you can take this one or not.
Firstly, I will console.log the data over here.
And open the terminal.
Now from I to VI, it means from the same friend to the from us.
Okay.
It means to send over here will be zone and receiver will be Thomas.
Right?
So, uh, it's back when I logged in with the Thomas account, I will see the sender name will be John.
Okay, so for this case I will click on friend request and I will remove the result.
Creators.
Let me reboot us.
Okay.
Remove the bandage over here.
And open again.
Click on send friend request.
Make sure in this case we should login with the.
Zone account okay.
Zone will send friend to the right by this thing and move over here with the friend.
Make sure you copy the ID from the Thomas.
Over here.
Okay.
And send that.
Now let's take a look at the data.
We already got the sender name.
Which zone?
It means we already So secondly, send the event right.
You will say right here the sender should be the commerce and it's already work, but it's not enough.
You can say in here this dot server is exactly the same with this.
Sorry with IO dot image.
Right.
It means with IO right here we actually send this message to on the client has connect to the server
right.
And you can taste good or not.
Well this not good at all.
We don't need to send.
The event into own client has to connect to the server.
This is not good at all for a reason.
In this case we should use Deals are so okay.
We need to use a tool and we need to move the receiver.
Okay.
We need to send from sorry.
We need to send a.
Width string and both receiver error.
Here let me explain to you what exactly that mean is here we should mark the receiver array.
Right.
So you can put receiver array directly from parameter over here.
Okay.
What actually does this mean right now I will explain for you.
Don't worry about the receiver idea right now.
But before that let me create one more thing called subscribe.
Subscribe.
This will be.
Uh, Let me say.
What is your name?
This is our.
Room.
Okay.
Go on.
Okay.
My real name.
Let us.
And we need to create a surprise message.
Okay, let me check the documentation to see.
Don't worry.
I'll explain why I do like that.
I don't remember to call.
Also, get over here.
Get Y and copy the message.
Right here we have something like here.
Okay, let me move that over here.
We have message body come from the client, right?
And we have one more thing we call a client.
So let's get over here.
Okay.
So let me ask you last.
Okay.
Let me show you what what I mean.
Are we above the socket over here?
And from the socket, what we need to do, we need to use client browser window.
Right here will be a user ID.
What is user ID over here?
So let me explain for you why I do.
That's why I create a subscribe message and why I create the same friend request and why to receive
value.
What exactly does that mean?
Well, firstly, let's see how we can join a room.
Well, for example, in order for a plugin on the front end.
Okay, we log in with the zone account.
Okay.
It means we need to write the socket for the one like this when the connect happen.
What we need to do when we need to join.
We need to send the event right here to zero.
Okay.
It mean right here.
We should write something like okay now.
Ah!
Sorry, doc.
Emmett.
We need to emit an event with a zero over here with the user id.
Okay.
With a user ID current user id where the current user ID comes from.
Maybe it comes from the redux.
Okay.
We took a look at the ID from Redux or the local storage.
I don't care about that right now.
Okay.
Important part right here.
When we connect we need to immediately Xyrem with exactly the same current user.
Why we need to do that.
Well, right now, if I logged in with own account.
Okay.
It means when I logged in without account.
We immediately zero inside the zone we use on the ID irony of this zone right here, for example, is
only here half a day.
One, it means we will light into the room.
One.
Right?
And in later, for example, if another client connects to the Mastercard, we have to determine whether
to allow the room to.
Right.
So with this guy, every time we connect into the WebSocket server, we immediately join into that room.
And since we already joined that room, it means right now let's think about what is the receiver.
The receiver here will be the Thomas right from the John I want to send.
Only for Thomas.
Right.
I want to send from John to Thomas.
It means the receiver ID right here will be the ID of Thomas.
us, right?
So whatever is on your list here, the server, it only sends the data into the format.
This will be clearly autonomous.
Right from the zone we send a message to the format.
Okay.
It means from the server we will send into the room of the Thomas receiver.
Allegro.
Here.
Remember the receiver Allegro here is a Thomas.
Okay.
So for that reason the receiver Allegro here will be will become ID Thomas.
We already saw before us.
Right.
So in order to use the two method, we should join us before.
Okay.
And in order to resolve that, we should join from the client.
Okay.
For that reason, we will create a subscribe message with this account.
Sorry.
With this event name.
I hope you're very clear right now.
Right.
Would you say with the best body will be the user ID roughly over here?
Okay.
And once you get it, will join into the room.
Okay.
For example, right here will be the zone.
Right.
It means over here.
We already.
Zone.
Over here.
Okay.
If we log in with Tomas, it means right here.
We will use Tomas.
Okay.
So with this team, we will send only for the receiver will be the Tomas right now.
Okay.
I hope you are very clear about that.
And this will be good for performance perspective and without message code.
Okay.
So I hope you understand right now.
And it's for the job.
So I will see you in the next one.