1
00:00:00,240 --> 00:00:05,760
In this part, we are going to a prayer, the service, I quote, such that you said, go to this page,

2
00:00:06,480 --> 00:00:09,840
enjoy the chat room inside the service side.

3
00:00:10,240 --> 00:00:14,130
So first we are going to create a helper functions in the server.

4
00:00:15,290 --> 00:00:20,680
So we go back to the surface side and under the server folder, we create a helper.

5
00:00:21,140 --> 00:00:21,490
Yes.

6
00:00:22,760 --> 00:00:24,440
And inside the server.

7
00:00:25,610 --> 00:00:32,630
Inside these Ultragaz we are going to create that uses a raid, and initially this is empty.

8
00:00:34,430 --> 00:00:41,330
And then we are going to create a at USA functions, which is equal to.

9
00:00:43,360 --> 00:00:52,210
Socket IP, because we are going to pass the socket IP, the user name, the user IP and also the IP.

10
00:00:53,590 --> 00:00:59,860
So for us, we are going to check whether the user already exists in this room.

11
00:01:01,780 --> 00:01:10,390
So we create a constant and then we are going to use the user to find and then to use it and then to

12
00:01:10,390 --> 00:01:19,150
find out the user thought, well, ID is equal, equal to the ID that we passed to these functions.

13
00:01:19,840 --> 00:01:28,640
And the user thought user ID use ICO to do with the idea that we pass to these functions.

14
00:01:28,900 --> 00:01:43,540
So the first thing is if we are going to return to error and the error is the user already sees in this

15
00:01:43,540 --> 00:01:51,880
role, if not exist, we are going to create the user of the topic that we passed in, including the

16
00:01:51,880 --> 00:01:57,580
socket ID and name the user ID and also the room ID.

17
00:01:58,030 --> 00:02:05,440
Not we create the user are going to push the user user list and then we are going to we turned to use

18
00:02:05,470 --> 00:02:14,440
the user object, but since they are the same name, they're going to just simply use we turn user and

19
00:02:14,440 --> 00:02:24,400
at last we are going to exploit this by using more exports is equal to act it, and now we just create

20
00:02:24,400 --> 00:02:25,930
one helper functions.

21
00:02:26,560 --> 00:02:31,900
So actually what we do here is there is a user list here.

22
00:02:32,140 --> 00:02:40,000
If there is a new user like this name is drawn and the user is one to fee and the rheumatiz one to a

23
00:02:40,000 --> 00:02:46,500
fee, and if the function see that is already exists, then it will return to Earth.

24
00:02:46,510 --> 00:02:49,300
Otherwise it will happen to this array.

25
00:02:49,600 --> 00:02:52,480
So we delete this and we back to the index.

26
00:02:53,170 --> 00:03:01,120
And first we are going to import these helper functions and then we create content that user is equal

27
00:03:01,120 --> 00:03:04,410
to require helper.

28
00:03:04,750 --> 00:03:09,860
And then here we are going to descend the joint U.

29
00:03:09,880 --> 00:03:19,390
N When the user joins these chat room, we are going to post name and the room ID and also the user

30
00:03:19,390 --> 00:03:28,810
ID and then it will be turned to Iraq and or the user if we are going to add user.

31
00:03:29,620 --> 00:03:38,470
So we have the property of socket IP, which is equal to the socket ID and the name.

32
00:03:38,650 --> 00:03:44,370
And since the name property and the where they are using the same path or the same string.

33
00:03:44,380 --> 00:03:48,640
So we just use one word, only part of the named name.

34
00:03:49,370 --> 00:03:54,010
And then also this is the same, we just use my ID and also they do the IP.

35
00:03:54,400 --> 00:04:04,340
So we are going to check if there's no error, if there's error and we are going to load the joint or

36
00:04:05,780 --> 00:04:13,210
else load the joint user and then display the user.

37
00:04:13,540 --> 00:04:16,720
So now we are going to add a kind of side to impeach the joint event.

38
00:04:16,720 --> 00:04:25,130
So we back to the chat and first, like home, we are going to import the eye of the socket.

39
00:04:25,180 --> 00:04:27,490
I'll change and also add that to the socket.

40
00:04:27,970 --> 00:04:31,720
And also we have to import the endpoint.

41
00:04:34,330 --> 00:04:36,650
And also, we have to use that, in fact.

42
00:04:37,630 --> 00:04:45,850
So now here we use to use effort and we are going to image first we are going to create a socket and

43
00:04:45,850 --> 00:04:56,260
then we use to emit and then we pass the name, which is the user name here and the room ID maybe we

44
00:04:56,500 --> 00:05:06,610
have to delete it and put it under the ID so it will have the bomb ID first and also the user I.D. equal

45
00:05:06,610 --> 00:05:08,050
to a user I.D..

46
00:05:08,350 --> 00:05:14,410
So I think we already said all the things and we can tried to enter the chat room.

47
00:05:14,740 --> 00:05:22,050
I think to make it more clear we should go to the help function and then we can also download the user

48
00:05:22,060 --> 00:05:30,280
these and then we display the users here and then we stop the server and then we.

49
00:05:31,690 --> 00:05:38,880
We stopped the surfer because we just want to clear the U.S. at least so now we sent Astron and then

50
00:05:38,880 --> 00:05:45,270
we go to Rome one and then we go to another Browsr and ask Tom and also go to Rome one.

51
00:05:46,470 --> 00:05:50,300
Now you can see the user list has gone and also, Tom.

52
00:05:51,500 --> 00:05:59,780
Now, if we open one more user and then we ask John again and go to one one now you can see there is

53
00:05:59,780 --> 00:06:00,290
an error.

54
00:06:00,290 --> 00:06:02,720
The user already exists in this room.

55
00:06:02,810 --> 00:06:04,550
So this already works.
