To handle the actual incoming HCB requests, we need to call the handle, connect all the handle client
method on the server object.
We also need to change the lead or the state of alert as per the request.
So inside the void loop, you need to write server the handle client.
After that, you need to write two statements, a valid one.
OK, let's copy the variable from here.
Flood, one state's.
Then.
We need to ride digital rights
led when one and make a tie.
Else we need to make it law.
So it could be this line here and make it look.
Now, something for the second blade if.
Ilse.
No.
And that if a lived two status is changed, we need to make a tie, otherwise make it look.
Now, this will change depending on the request, so that handle client will handle the incoming data
and depending on the request, it will turn the light on or off.
Now, this will be more clear when we create a function to attach it to the root directory.
You are Al.
As you can see here, we initiated the handle and cannot handle it one on and one off hand the lid to
on and handle it to off and handle around.
These are all functions that we need to declare.
Now to declare these functions.
Now, the handle Connecticut will be as follows at the start of this function, we need to set the state
or the status of these two leads to law, which means that they will be off and print that state on
the serial monitor to make sure that everything is working just fine.
And in order to respond to that request, we use the same method.
Although that method can be called with a different set of arguments, it's simplest form consists of
the city response called the content type and the content.
In our case, we need to send that 200 request.
Let's first create the method now outside the void law.
You need to create your new method.
And to do that, what you need to do is simply write void and the them name handle on Connect.
Now inside this method, we will like few things.
The first thing is the let one state status.
We will make it law led to status will also be law, serial, dot, print.
We are going to print a line to make sure that everything is written correctly.
This first line, uh, Lyd or g.P I or two of.
And GPI, all five is also off, this one will make sure that whenever this method is called, we will
see this line and that monitor.
You can't ignore it if you don't want to know.
But I prefer adding these for debugging.
OK, now you need this is the most important line you need to server.
That sent and between the two parentheses, you need to write the following, the first argument will
be the code.
We are sending the code 200 in this case, the unconvicted case.
And this code will help us in many ways.
The first way that this squad will help us with is there's more than one status code for requests,
as you can see on this page.
You can write a list of HIV status code, I will add them and the resources of this course, and you
can as you can see here, 200 means, OK, so whenever we write 200, this means that it's OK to receive
this.
You are alone and we can handle it.
So we will use it.
We were like 200 here.
And after 200, you need to write or to specify the content type.
In our case, it will be out page text, slash HTML.
Now the third palmtop that you have to write is the content itself.
We are going to send e-mail and and this send a signal method.
We are going to write two parameters.
The first one is led one status.
And the second one will be led to theaters which are basically low and low, so it will send low and
low ground here.
The actual method will be discussed later.
Now.
To make sure that you understand what happened here in our case, we are sending the code 200, which
is one of the HCB status requests or codes that corresponds to the OK response, then we are specifying
the content type to be is text or e-mail.
And finally, we are calling to send a signal custom function, which creates a dynamic e-mail page
containing status of these two letters.
So this will be created later in usability lesson, but that's it for now.
This is how to create the first method that will be called whatever we call this.
You are the men you are and it will call hands on Connect.
Now, we have to do the same for all of these methods, as you can see.
So let's start.
Likewise, we need to create four functions to handle all of our requests and the 404 error page.
To do this easily, we can't simply copy this method and based it down below here and here, we can
fight late one on.
And L'Etoile status will be high.
We don't need that little status, and in our case, this will mean that this line will be like this
on.
Now, the server sent will send 200, OK, and the time will be text and ascherman, the sender Shamal
method will send through and the two states will be the same.
Now, to do this for the second copy and paste, right, let one off now here hearing it right law.
Of I think that now you did get the idea and you can do this on your own, you can complete the remaining
four methods.
Now.
We need to copy these two methods now, we have four methods, this will be two and the two.
General-Purpose input output to number five here and five here.
The first one would be number two here.
And to hear what we have just to fix this, because we connected their lives to a number two and five.
So two on five.
OK.
To five now we have to change these two.
This will be loved one status and this will be true.
This will be.
Loved status, and this would be false.
OK, now we have to change these lines, everything is right, there is one more method that we need
to create, which is the 404 not found method.
Not found.
Not found, no.
The not found will have only one.
Line not found and we don't need any red states, and here we try the code 404 for not found and simply
right not found.
OK, that's it.
This is how you can create all of these methods.
Now, there is still one method and e-mail that we need to create, but let's combine the code to make
sure that there is no else other than the standard Shamala.
Kay.
This is the handle on Connect.
Now, to fix this error, we need just to change the tone, we must build this line with capital on
this.
Now verify again.
OK, now.
OK, now we have the Sinochem al method, which has errors, and we are going to fix this while going
to create this method in the next lesson.
But let's make a quick summary of what we have done here in this code.
Now, the first thing that we did here is create inside the void loop.
We call the handle client method and we bust the lid status using this if statement late one and led
to high or low, depending on the alert one status.
Now, once the handle and connect methods are called, each of them will do something.
Now the interconnect the first method for the manual will set that relates to the load mode, will turn
them off and will print this on the third monitor and it will send this 200 means, OK, this is the
content type and it will send the status of these two letters and submit them on our Shamal page.
And we are going to explain how to do that in the next lesson.
Same thing for other methods.
All of these methods are declared based on this server that on line, as you can see, if the line was
lit, one on means that it will tell that it one on the second line and one oft means it will call the
hand a one off method.
So we created methods for all of these lines.
And we added our code inside each of these methods to turn the lid off and possibly a sentence that
this lid is now off and to send an e-mail page showing that this lid or lid one is off, OK?
Now, the next lesson we are going to create, that's a sham.
And you are going to write or create our e-mail code or page.
Thanks for asking.
This is Asharaf from educational engineering team.