Hello and welcome to the Gold Anchor Academy language course in the previous session.
We could define create IP function, and in this session we want to create another function.
The main metal in the client should be contains two functions.
First, the function for receiving message and second, the function for sending a message.
Now we go to implement the receive message function for do this create a new function name like receive
message.
So we right fine.
Receive
message.
This function, except it parameters, point of VIPs to get connection, so set the variable light connection
by the time point of that circuit connection.
That connects.
We use infinite loop, therefore our function is always ready to receive the message.
So right for
now, given to receive a message from client to do these views from Jason Cadec, Jason is a codec to
send or receive JSON data in a frame from events to get the conviction.
So from that, to get package calling Jason and invoking receive method, this method returns and it
also defined invariant and like of a roll calling equals.
We have two kids.
Jason?
Dont receive this method, accept two parameters.
First, the clinics in Seoul visit 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 in messages to object here.
Therefore, first define an object from messages throughout and pass it as pointer the function.
So define a variable like VAR message from messages that I've could package that message.
And set this very in a second argument for reserve function.
OK, now implements erode status, if at all not equals, Neal.
Lock the Fattore and set the message at all and receive state talent and said, I don't message if there
is an error.
The program should not be stopped and should continue to work.
So use continue command and go to the next line and continue.
And if there is no, it will print the message, so be right, if the
message is and said message got subject.
We were able to implement the receive message function.
Now we can the created function inside the main method as a separate go routine.
So go to main function.
And calling receive message as a good routine, but before you check every state, if they're not equals
mean, the log dots fatal error dot at all.
And now receive my state as the gold routine go routine receive message and that connection as argument
for connection.
So top of calling this off message function to make sure our connection is closed after this event is
done.
A close connection by the common deeper connection close.
So, right, defer connection that close.
Now we go to implement the send message for do these create a new function named like send message?
So go after to receive message promotion and create another function like fine send message.
This function, I accept the parameterized Paul introverts to get the connection.
So set a variable like connection by the time point of that connection.
OK.
To get the value from the standard input we use, the newest cannot function from both I or package
and create a scanner.
This function returns and munis cannot read from a reader.
So first, define a variable like a scanner scanner column e calls from both or package calling new
scanner function new scanner.
Set a standard input from always packaged as argument for the sponsor if the event is open fires pointing
to the standard input.
So the right OS got tested, I had to retain information in this scanner.
We need a for loop and this volume is activated when the user has sent information via input a standard,
and we do this by invoking the scan function.
So go to the next line.
Full scanner
calling a scan function.
If the user enters information inside based on their input, the program infers the full loop and this
can function is called and reads the information in the scanner and we get it scanner data by calling
text function.
So first, define the value of a like text
text column.
He equals scanner dart text.
Now we send the receive data inside that takes very able to the server via adjacent formats.
We do this by calling Send Metal France wicket package sent metal access to parameters first the connection.
Second is an object.
In this case, our argument is an object from messages struct.
So before cutting send function, we create the message variable and initialize the subject field of
message is struck by the text field value.
So we write message.
Calling equal socket.
Dot mrJ
and initialise subject by text Lalibela.
Oh, here we named Test, we changed it to text.
OK, now calling same function, this function returns and enter object, so we define an error value
in error column equals left sutured dot jason
dot 7th function and sip connection as a first argument connection and sip message a second argument
message.
Now check it out.
A status, if add or not, means display on the roof.
If be.
Error in send data and set error valid
if there is an error, the program should not be stopped and should continue to work.
So use continue command, go to the next line and continue.
OK.
We were able to implement the decent message function.
Now we called the created function inside the main metal.
So go to main method.
And right, the function send a message and that connection is argument for it.
Before that, they called Save the Project.
In this case, we could implement the client line in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.