WEBVTT

1
00:00.520 --> 00:01.800
Hi everyone.

2
00:01.800 --> 00:08.280
In this video we will answer some questions in your head.

3
00:09.040 --> 00:19.640
Now you may ask me right here if you see in the WebSocket server we have a WebSocket.

4
00:20.240 --> 00:28.760
And inside the callback over here we only interact with the socket callback over here.

5
00:29.320 --> 00:31.240
But why the script right here?

6
00:31.240 --> 00:36.600
It doesn't have anything like socket or something like that okay.

7
00:36.640 --> 00:44.680
Why does it have and why it interact directly into the socket over here okay.

8
00:45.480 --> 00:53.960
And why we not to interact the directly with the WebSocket over here.

9
00:54.280 --> 00:54.760
Why?

10
00:55.200 --> 00:55.640
Okay.

11
00:55.680 --> 01:02.910
I know it very confusing at the beginning Because that's my story.

12
01:03.230 --> 01:03.750
Okay.

13
01:03.990 --> 01:11.910
When the first time I learned, I will ask the question why?

14
01:12.230 --> 01:12.870
Like this?

15
01:14.230 --> 01:17.950
And in this video, let me answer the question.

16
01:18.670 --> 01:19.190
Okay.

17
01:19.550 --> 01:25.710
Firstly, you can see when we establish a WebSocket we will got the socket.

18
01:25.950 --> 01:26.470
Okay.

19
01:27.230 --> 01:29.670
So what exactly about socket.

20
01:30.070 --> 01:38.870
The socket right here is a endpoint between the client and server okay.

21
01:39.030 --> 01:46.950
For example, from the computer A, if we want to send data into the computer B okay, we.

22
01:49.390 --> 01:54.310
The computer a a also have some port.

23
01:55.070 --> 01:59.270
For example like this arrow here is a client okay.

24
01:59.670 --> 02:01.590
And the client.

25
02:02.510 --> 02:07.350
Maybe it will a random part and B right here in a server.

26
02:07.630 --> 02:10.070
Maybe it will have a 3000.

27
02:10.470 --> 02:10.990
Okay.

28
02:11.670 --> 02:19.950
And in order to send using the WebSocket over here, we will create the socket okay.

29
02:20.630 --> 02:21.150
Okay.

30
02:22.550 --> 02:25.350
The socket endpoint between the.

31
02:27.430 --> 02:31.510
Client and specific server.

32
02:32.590 --> 02:33.110
Okay.

33
02:33.750 --> 02:38.150
Now the first thing I want to show you is what it is socket.

34
02:40.150 --> 02:44.270
And you can see one server, it might be.

35
02:44.270 --> 02:47.950
Have so many clients okay.

36
02:48.310 --> 02:49.870
It have so many clients.

37
02:54.990 --> 02:59.830
But you can see one client only have one server, okay.

38
03:00.190 --> 03:05.350
Okay, so that's in a relationship right now.

39
03:05.910 --> 03:14.510
The one to many relationship between the server and client.

40
03:15.310 --> 03:24.590
One server can have multiple clients, but many clients only have one server.

41
03:24.750 --> 03:25.270
Okay.

42
03:26.310 --> 03:27.350
Notice about that.

43
03:27.550 --> 03:35.990
So for that reason in this case we don't have anything like WebSockets in the client side.

44
03:36.270 --> 03:46.630
Because by the end of day, the client over here is only have one server okay.

45
03:46.670 --> 03:48.550
It doesn't have another server.

46
03:50.630 --> 03:51.670
For that reason.

47
03:51.710 --> 03:55.230
We don't need anything like socket over here.

48
03:57.190 --> 04:00.300
But the server is a different story.

49
04:00.740 --> 04:01.620
Because.

50
04:03.660 --> 04:13.740
Once server can have multiples clients, for that reason, we need the WebSockets right here to know

51
04:14.380 --> 04:16.540
the specific client.

52
04:16.740 --> 04:17.300
Okay.

53
04:18.980 --> 04:26.580
It will with the WebSocket over here, it will identify what exactly the client connect to the server.

54
04:26.820 --> 04:32.460
For example inside here inside here this is the one client right.

55
04:32.500 --> 04:33.700
This one client.

56
04:34.020 --> 04:38.460
And if I duplicate you can see I will connect.

57
04:39.180 --> 04:42.180
It will connect okay.

58
04:43.260 --> 04:47.340
And one more thing it will connect one more thing okay.

59
04:49.260 --> 04:53.500
So that is that's about the relationship.

60
04:53.660 --> 04:56.380
And from now I hope you already understand.

61
04:56.700 --> 05:05.660
Okay let me summarize, the socket right here is only belong to the specific server

62
05:05.820 --> 05:06.580
for a reason.

63
05:06.580 --> 05:14.980
It doesn't need anything like WebSocket inside the callback, and it will interact back to the server

64
05:15.260 --> 05:17.060
using directly socket.

65
05:17.500 --> 05:25.540
Okay, because from here we clearly know this only connects to that server.

66
05:27.140 --> 05:27.700
Okay.

67
05:28.740 --> 05:42.700
And with the server connection right here, we have a callback because with the socket inside callback

68
05:42.740 --> 05:52.460
over here we will know what Specificed client try to connect to the server.

69
05:55.540 --> 05:58.340
So I hope you are clear right now.

70
05:58.540 --> 05:59.740
I will see you in the next.