1 00:00:00,690 --> 00:00:07,920 To handle the actual incoming HCB requests, we need to call the handle, connect all the handle client 2 00:00:07,920 --> 00:00:10,410 method on the server object. 3 00:00:11,160 --> 00:00:16,190 We also need to change the lead or the state of alert as per the request. 4 00:00:16,920 --> 00:00:23,540 So inside the void loop, you need to write server the handle client. 5 00:00:25,560 --> 00:00:31,560 After that, you need to write two statements, a valid one. 6 00:00:33,870 --> 00:00:35,940 OK, let's copy the variable from here. 7 00:00:37,790 --> 00:00:39,200 Flood, one state's. 8 00:00:43,030 --> 00:00:43,510 Then. 9 00:00:45,640 --> 00:00:49,780 We need to ride digital rights 10 00:00:53,470 --> 00:00:57,850 led when one and make a tie. 11 00:01:00,230 --> 00:01:05,110 Else we need to make it law. 12 00:01:12,040 --> 00:01:16,270 So it could be this line here and make it look. 13 00:01:19,740 --> 00:01:25,170 Now, something for the second blade if. 14 00:01:27,340 --> 00:01:28,030 Ilse. 15 00:01:31,270 --> 00:01:31,810 No. 16 00:01:33,870 --> 00:01:45,360 And that if a lived two status is changed, we need to make a tie, otherwise make it look. 17 00:01:53,840 --> 00:02:00,820 Now, this will change depending on the request, so that handle client will handle the incoming data 18 00:02:00,830 --> 00:02:04,580 and depending on the request, it will turn the light on or off. 19 00:02:05,330 --> 00:02:12,490 Now, this will be more clear when we create a function to attach it to the root directory. 20 00:02:12,530 --> 00:02:13,190 You are Al. 21 00:02:14,790 --> 00:02:23,400 As you can see here, we initiated the handle and cannot handle it one on and one off hand the lid to 22 00:02:23,400 --> 00:02:27,220 on and handle it to off and handle around. 23 00:02:27,240 --> 00:02:29,760 These are all functions that we need to declare. 24 00:02:31,200 --> 00:02:33,930 Now to declare these functions. 25 00:02:36,250 --> 00:02:44,230 Now, the handle Connecticut will be as follows at the start of this function, we need to set the state 26 00:02:44,410 --> 00:02:53,140 or the status of these two leads to law, which means that they will be off and print that state on 27 00:02:53,140 --> 00:02:56,830 the serial monitor to make sure that everything is working just fine. 28 00:02:57,460 --> 00:03:02,530 And in order to respond to that request, we use the same method. 29 00:03:03,160 --> 00:03:10,090 Although that method can be called with a different set of arguments, it's simplest form consists of 30 00:03:10,090 --> 00:03:15,310 the city response called the content type and the content. 31 00:03:15,970 --> 00:03:20,370 In our case, we need to send that 200 request. 32 00:03:20,380 --> 00:03:23,620 Let's first create the method now outside the void law. 33 00:03:24,760 --> 00:03:27,070 You need to create your new method. 34 00:03:29,040 --> 00:03:40,700 And to do that, what you need to do is simply write void and the them name handle on Connect. 35 00:03:43,350 --> 00:03:46,140 Now inside this method, we will like few things. 36 00:03:46,740 --> 00:03:51,060 The first thing is the let one state status. 37 00:03:51,090 --> 00:04:03,960 We will make it law led to status will also be law, serial, dot, print. 38 00:04:05,040 --> 00:04:11,250 We are going to print a line to make sure that everything is written correctly. 39 00:04:11,430 --> 00:04:20,490 This first line, uh, Lyd or g.P I or two of. 40 00:04:23,270 --> 00:04:34,820 And GPI, all five is also off, this one will make sure that whenever this method is called, we will 41 00:04:34,820 --> 00:04:36,700 see this line and that monitor. 42 00:04:37,760 --> 00:04:41,000 You can't ignore it if you don't want to know. 43 00:04:41,490 --> 00:04:43,670 But I prefer adding these for debugging. 44 00:04:44,120 --> 00:04:48,680 OK, now you need this is the most important line you need to server. 45 00:04:50,790 --> 00:04:58,200 That sent and between the two parentheses, you need to write the following, the first argument will 46 00:04:58,200 --> 00:04:58,860 be the code. 47 00:04:59,460 --> 00:05:04,110 We are sending the code 200 in this case, the unconvicted case. 48 00:05:07,580 --> 00:05:10,100 And this code will help us in many ways. 49 00:05:12,750 --> 00:05:21,420 The first way that this squad will help us with is there's more than one status code for requests, 50 00:05:21,690 --> 00:05:23,070 as you can see on this page. 51 00:05:24,460 --> 00:05:30,370 You can write a list of HIV status code, I will add them and the resources of this course, and you 52 00:05:30,370 --> 00:05:37,960 can as you can see here, 200 means, OK, so whenever we write 200, this means that it's OK to receive 53 00:05:37,960 --> 00:05:38,290 this. 54 00:05:38,290 --> 00:05:40,630 You are alone and we can handle it. 55 00:05:41,020 --> 00:05:42,090 So we will use it. 56 00:05:42,100 --> 00:05:43,390 We were like 200 here. 57 00:05:45,250 --> 00:05:51,100 And after 200, you need to write or to specify the content type. 58 00:05:51,250 --> 00:05:57,650 In our case, it will be out page text, slash HTML. 59 00:05:59,410 --> 00:06:06,820 Now the third palmtop that you have to write is the content itself. 60 00:06:07,150 --> 00:06:15,300 We are going to send e-mail and and this send a signal method. 61 00:06:15,310 --> 00:06:19,030 We are going to write two parameters. 62 00:06:19,880 --> 00:06:25,600 The first one is led one status. 63 00:06:29,570 --> 00:06:37,130 And the second one will be led to theaters which are basically low and low, so it will send low and 64 00:06:37,130 --> 00:06:38,140 low ground here. 65 00:06:38,620 --> 00:06:42,890 The actual method will be discussed later. 66 00:06:43,880 --> 00:06:44,450 Now. 67 00:06:45,840 --> 00:06:51,870 To make sure that you understand what happened here in our case, we are sending the code 200, which 68 00:06:51,870 --> 00:07:00,540 is one of the HCB status requests or codes that corresponds to the OK response, then we are specifying 69 00:07:00,540 --> 00:07:03,930 the content type to be is text or e-mail. 70 00:07:04,710 --> 00:07:13,080 And finally, we are calling to send a signal custom function, which creates a dynamic e-mail page 71 00:07:13,440 --> 00:07:16,170 containing status of these two letters. 72 00:07:17,760 --> 00:07:25,090 So this will be created later in usability lesson, but that's it for now. 73 00:07:25,110 --> 00:07:30,480 This is how to create the first method that will be called whatever we call this. 74 00:07:30,780 --> 00:07:35,220 You are the men you are and it will call hands on Connect. 75 00:07:35,260 --> 00:07:39,600 Now, we have to do the same for all of these methods, as you can see. 76 00:07:41,150 --> 00:07:43,080 So let's start. 77 00:07:43,100 --> 00:07:50,720 Likewise, we need to create four functions to handle all of our requests and the 404 error page. 78 00:07:52,400 --> 00:08:00,980 To do this easily, we can't simply copy this method and based it down below here and here, we can 79 00:08:01,460 --> 00:08:02,690 fight late one on. 80 00:08:04,410 --> 00:08:06,940 And L'Etoile status will be high. 81 00:08:08,640 --> 00:08:18,120 We don't need that little status, and in our case, this will mean that this line will be like this 82 00:08:18,120 --> 00:08:18,480 on. 83 00:08:19,920 --> 00:08:27,770 Now, the server sent will send 200, OK, and the time will be text and ascherman, the sender Shamal 84 00:08:27,780 --> 00:08:34,860 method will send through and the two states will be the same. 85 00:08:36,280 --> 00:08:46,420 Now, to do this for the second copy and paste, right, let one off now here hearing it right law. 86 00:08:48,780 --> 00:08:58,440 Of I think that now you did get the idea and you can do this on your own, you can complete the remaining 87 00:08:58,440 --> 00:08:59,220 four methods. 88 00:09:00,570 --> 00:09:01,110 Now. 89 00:09:02,130 --> 00:09:11,070 We need to copy these two methods now, we have four methods, this will be two and the two. 90 00:09:12,440 --> 00:09:19,550 General-Purpose input output to number five here and five here. 91 00:09:21,550 --> 00:09:23,410 The first one would be number two here. 92 00:09:24,720 --> 00:09:31,380 And to hear what we have just to fix this, because we connected their lives to a number two and five. 93 00:09:32,790 --> 00:09:33,990 So two on five. 94 00:09:34,100 --> 00:09:34,470 OK. 95 00:09:35,940 --> 00:09:42,160 To five now we have to change these two. 96 00:09:43,260 --> 00:09:47,930 This will be loved one status and this will be true. 97 00:09:49,350 --> 00:09:50,100 This will be. 98 00:09:52,430 --> 00:09:54,680 Loved status, and this would be false. 99 00:09:58,780 --> 00:10:06,430 OK, now we have to change these lines, everything is right, there is one more method that we need 100 00:10:06,430 --> 00:10:11,950 to create, which is the 404 not found method. 101 00:10:14,090 --> 00:10:15,170 Not found. 102 00:10:17,400 --> 00:10:22,080 Not found, no. 103 00:10:23,580 --> 00:10:26,670 The not found will have only one. 104 00:10:27,710 --> 00:10:40,750 Line not found and we don't need any red states, and here we try the code 404 for not found and simply 105 00:10:40,750 --> 00:10:45,260 right not found. 106 00:10:47,110 --> 00:10:48,680 OK, that's it. 107 00:10:48,700 --> 00:10:53,470 This is how you can create all of these methods. 108 00:10:53,680 --> 00:10:59,320 Now, there is still one method and e-mail that we need to create, but let's combine the code to make 109 00:10:59,320 --> 00:11:03,490 sure that there is no else other than the standard Shamala. 110 00:11:07,440 --> 00:11:07,950 Kay. 111 00:11:11,150 --> 00:11:13,760 This is the handle on Connect. 112 00:11:16,840 --> 00:11:26,790 Now, to fix this error, we need just to change the tone, we must build this line with capital on 113 00:11:26,790 --> 00:11:27,140 this. 114 00:11:28,770 --> 00:11:29,910 Now verify again. 115 00:11:35,590 --> 00:11:36,580 OK, now. 116 00:11:37,800 --> 00:11:44,520 OK, now we have the Sinochem al method, which has errors, and we are going to fix this while going 117 00:11:44,520 --> 00:11:46,640 to create this method in the next lesson. 118 00:11:47,100 --> 00:11:51,580 But let's make a quick summary of what we have done here in this code. 119 00:11:52,140 --> 00:11:58,770 Now, the first thing that we did here is create inside the void loop. 120 00:11:59,130 --> 00:12:10,850 We call the handle client method and we bust the lid status using this if statement late one and led 121 00:12:10,860 --> 00:12:14,640 to high or low, depending on the alert one status. 122 00:12:15,480 --> 00:12:22,710 Now, once the handle and connect methods are called, each of them will do something. 123 00:12:23,040 --> 00:12:30,870 Now the interconnect the first method for the manual will set that relates to the load mode, will turn 124 00:12:30,870 --> 00:12:38,430 them off and will print this on the third monitor and it will send this 200 means, OK, this is the 125 00:12:38,430 --> 00:12:45,810 content type and it will send the status of these two letters and submit them on our Shamal page. 126 00:12:46,260 --> 00:12:49,510 And we are going to explain how to do that in the next lesson. 127 00:12:50,640 --> 00:12:52,520 Same thing for other methods. 128 00:12:52,920 --> 00:13:00,810 All of these methods are declared based on this server that on line, as you can see, if the line was 129 00:13:00,810 --> 00:13:09,570 lit, one on means that it will tell that it one on the second line and one oft means it will call the 130 00:13:09,620 --> 00:13:11,310 hand a one off method. 131 00:13:11,730 --> 00:13:15,690 So we created methods for all of these lines. 132 00:13:17,060 --> 00:13:24,260 And we added our code inside each of these methods to turn the lid off and possibly a sentence that 133 00:13:24,260 --> 00:13:34,020 this lid is now off and to send an e-mail page showing that this lid or lid one is off, OK? 134 00:13:34,250 --> 00:13:38,660 Now, the next lesson we are going to create, that's a sham. 135 00:13:38,710 --> 00:13:44,720 And you are going to write or create our e-mail code or page. 136 00:13:44,990 --> 00:13:45,890 Thanks for asking. 137 00:13:45,890 --> 00:13:48,620 This is Asharaf from educational engineering team.