Hello and welcome to the Golang programming language course in the Pentagon session.
We could define Mark's server, and in this session we want to create the website, get home for the
and function in the mock survey created.
We said to Rhonda, Let's look at the root of the project.
We need to create the function for the vets to get to be able to manage the request.
Therefore, we create the function name like vets who get handler, so define
fun
with some handler.
Dysfunction accepts two parameters.
First, the connection from point of let's get the connection.
So we said connection.
As pointed of that's occurred, connection
and second parameter is another object from the config extract of snooker player because we want to
a thought we circuit method of config Astra.
So we said config from pointer off sutured.
Afghan week.
First, we start created circuit.
We do this by combining one circuit method from circuit package because it runs circuit method is running
in the background of the program and examines the channels the call to dismantle it must be executed
in a separate go routine.
So here I go, Colin Rustica function from config package config.
Don't run, Sujit.
Now, first client enters the program, we have to add this client to the list of clients, which we
do through the registered client channel, so we write from config.
The call registered client raises the client and that connection to the China
connection to the track.
Now we could add a new client to the list of clients.
This server now has to wait and listen.
Whether a message comes to eat from the client or not, if a message is sent from the client to the
server server receives and this realizes it and then sends it to other clients for do this first define
an infinite loop.
For
now, we want to reset the message from client to do these views from Jason Kotick.
Jason is according to send or receive JSON data in a frame from that a connection.
So from let's get package calling JSON and invoke it Greece's method.
This method returns, and it also defines a variable like error.
Calling equals that's occurred.
Dot, Jason
Dot.
Receive.
This method accept two parameters.
First, the connection, so we said connection
and another object is needed a second parameter to be able to put the received data inside it after
the serializing.
So we are using a message, a sort of object here.
Therefore, first define the object from messages throughout and pass it as pointer to function.
So first, define a variable like
that message from messages.
Drop off, switch a package.
And now sit as pointer to the function and person message.
Now implements at all stages, if at all not equals need, if the calling recieve method returns an
error of value, we must remove the client from the list of the clients to do this call to remove Client
Channon from the convict package and send the current client to eat.
So we tried Con Fiqh do not remove client and CIT connection to channel
connection.
In this case, the server should not to stop and continue to work, so use the Continue Command continue.
Now, if there is no error, the received message should be sent to each client.
Do this by sending message to message data channel of config package.
So be right.
Config dot message data and sent to Channon message, reformat the code and save the project.
We were able to implement a handler for red sutured.
Now it's time to introduce the created function as handler into red Sujit to do this.
Enter the main method and call the created method inside the vets the cat handler.
Go to main the tool.
Now, calling that secret handler function for first argument, he said connection.
And for second argument, first, we define an object from configures drive by calling nuclear-free
constructor from circuit package.
So first, define a variable like config column equals and calling new config constructor frames to
create package.
So the new feat now set config variable, a second argument for which ticket handler can't.
OK.
We were able to implement the server layer in order not to prolong the time of decision, even finish,
and we will continue the content in the next session.
Goodbye.