1 00:00:11,990 --> 00:00:17,450 Hello and welcome to the Gold Lounge programming language course in the pit of your session. 2 00:00:17,720 --> 00:00:24,980 We were able to complete the package related to a PC controller and in this session we want to go to 3 00:00:24,980 --> 00:00:26,660 create the main package. 4 00:00:26,840 --> 00:00:38,960 So we'll go to the Project Explorer, create a new folder named name and create a new file like made 5 00:00:38,960 --> 00:00:39,710 that will 6 00:00:45,200 --> 00:00:46,640 now set Package Main. 7 00:00:51,020 --> 00:00:55,430 First, define two function for communication between client and server. 8 00:00:56,030 --> 00:01:02,690 First, create a function for running client that enabled it, for example, around your PC client. 9 00:01:03,170 --> 00:01:07,670 So right from wrong. 10 00:01:09,700 --> 00:01:14,200 Do your PC clients. 11 00:01:18,250 --> 00:01:25,270 And create another function for running server that we named it, for example, Rongji, our PC server 12 00:01:26,560 --> 00:01:27,320 farms. 13 00:01:29,130 --> 00:01:34,650 Ron, G.R., PC, sir. 14 00:01:40,340 --> 00:01:46,070 Before we want to use Ron G.R. PCs service, we need to create a connection to the database. 15 00:01:46,610 --> 00:01:52,790 Previously, we designed the method called G.R. PC Server Initialize or in the server package. 16 00:01:53,210 --> 00:02:00,530 It contains a method called connect from the DV Tools package, which by taking two values of driver 17 00:02:00,530 --> 00:02:05,720 name and data source name, creates a connection to the MySQL database. 18 00:02:07,070 --> 00:02:13,580 The answer previous, is save driver name and data source name information inside the JSON find in the 19 00:02:13,580 --> 00:02:15,350 configuration package. 20 00:02:15,500 --> 00:02:23,390 Now you can see it now it's time to use the information in our JSON file to connect to the database 21 00:02:24,110 --> 00:02:32,420 for using the JSON, find the calling open function from OS Paquet that opens the named file for reading. 22 00:02:32,660 --> 00:02:40,070 If successful methods on the return file can be used for reading this function, accept foreign passes, 23 00:02:40,070 --> 00:02:43,050 input parameter and returns to values. 24 00:02:43,070 --> 00:02:47,190 First, no object from file and the other an object from error. 25 00:02:48,200 --> 00:02:58,760 So first, go to the main file and create a main function for me. 26 00:03:02,630 --> 00:03:10,400 Now we defined two variables named Fong and Error for cutting the open function for almost four decades. 27 00:03:10,640 --> 00:03:20,920 Five Rule call equals cutting open function from voice package. 28 00:03:24,110 --> 00:03:38,850 And said, Jason, final pass as input parameter as string type can, the creation is less config dot. 29 00:03:39,350 --> 00:03:49,280 Jason first check error tools if error not equals need 30 00:03:53,840 --> 00:03:57,590 like dot matter and all 31 00:04:01,280 --> 00:04:02,100 that off. 32 00:04:05,000 --> 00:04:10,970 We use DFA for closing the created file object, so we write Ether. 33 00:04:12,510 --> 00:04:14,190 Find close. 34 00:04:20,010 --> 00:04:27,480 Now, create this right on top of the main menu that contains valuable equivalent to the keys in the 35 00:04:27,480 --> 00:04:33,060 Jason fine that are used to map those keys to their data types and go land. 36 00:04:33,540 --> 00:04:36,540 So defining a site like name configuration 37 00:04:38,910 --> 00:04:39,660 type, 38 00:04:42,690 --> 00:04:45,000 can he Grecian? 39 00:04:45,990 --> 00:04:46,670 Let's try 40 00:04:50,610 --> 00:04:50,980 try. 41 00:04:51,300 --> 00:05:00,160 Their name and type is extreme string and using Jason. 42 00:05:00,180 --> 00:05:03,390 Thank you, Jason. 43 00:05:06,570 --> 00:05:08,670 Colin sit name. 44 00:05:16,260 --> 00:05:31,290 Drive her name and go to the next line and define another key data, source name and type is history 45 00:05:32,100 --> 00:05:32,850 using Jason. 46 00:05:32,850 --> 00:05:37,500 Thank you, Jason. 47 00:05:37,590 --> 00:05:43,380 Colin and set name data source name. 48 00:05:45,600 --> 00:05:48,690 Now define an object from configuration extract. 49 00:05:48,780 --> 00:05:58,200 So define a variable like that comes from configuration extract. 50 00:06:00,470 --> 00:06:01,340 Equals 51 00:06:03,890 --> 00:06:04,700 functionaries 52 00:06:08,300 --> 00:06:16,970 now using the new decoder, a function of the Jason package, we send the Jason fine to eat as a parameter 53 00:06:16,970 --> 00:06:22,220 after opening it and through the Decode Metal and reads the next J. 54 00:06:22,220 --> 00:06:29,180 Some encoded value from its input and is stored in the value pointed to object created from the configuration 55 00:06:29,180 --> 00:06:29,330 is. 56 00:06:30,020 --> 00:06:34,010 So go to the main function and after defer find. 57 00:06:35,150 --> 00:06:35,900 Be right. 58 00:06:35,900 --> 00:06:39,320 Jason Dot. 59 00:06:40,060 --> 00:06:41,810 Neil Decoder. 60 00:06:44,470 --> 00:06:52,760 And set fire as parameter dot and decode Anderson. 61 00:06:58,840 --> 00:07:05,800 This allowed us to absorb the values inside the JASON find in the variables in the configuration is 62 00:07:05,800 --> 00:07:06,310 trust. 63 00:07:07,900 --> 00:07:12,160 We can send parameters to the program at wrong time by the console. 64 00:07:12,160 --> 00:07:20,650 Lying flat package has the ability to read and receive decent parameters and provides them to the program. 65 00:07:21,070 --> 00:07:24,040 So in this part, we use the flag package. 66 00:07:24,850 --> 00:07:31,270 Google provides a flag package supporting basic command line flag, passing the use this package to 67 00:07:31,270 --> 00:07:33,460 implement our Example Command Line program. 68 00:07:34,120 --> 00:07:41,020 If you remember in the topic of protocol author, we fully explained how to use the flag package. 69 00:07:41,710 --> 00:07:44,140 Now let's go to create the flag parameter. 70 00:07:44,540 --> 00:07:49,150 First, define a variable and calling a string function from the flag package. 71 00:07:50,020 --> 00:07:57,940 Assign function defines the assigned flag with a specified name, default value and use a string. 72 00:07:58,300 --> 00:08:03,310 The return value is the address of this string variable that distorts the value of the flag. 73 00:08:03,520 --> 00:08:06,310 First, define the variable light option. 74 00:08:09,980 --> 00:08:15,140 Colin equals cutting string function from the flag by his flag 75 00:08:18,890 --> 00:08:20,150 dart string. 76 00:08:24,420 --> 00:08:28,290 Set a name for the flag, for example, at me 77 00:08:31,260 --> 00:08:33,390 and set a value for the flag. 78 00:08:33,540 --> 00:08:35,760 For example, a server 79 00:08:38,730 --> 00:08:44,880 and set a description of the flag for the example, a communication 80 00:08:47,700 --> 00:08:51,990 between server and client. 81 00:08:54,900 --> 00:09:01,650 Some of the register estimated flag with a string function now calling pass function from flag package 82 00:09:03,630 --> 00:09:06,870 flag to art pass. 83 00:09:12,140 --> 00:09:20,030 Pass Fonctionnent passes the common line flag from Ozarks must be called after all flags are defined 84 00:09:20,030 --> 00:09:22,760 and before flags are accessed by the program. 85 00:09:23,780 --> 00:09:31,070 Now, by inserting a search, we analyzed the value of recent flags and decide what the program will 86 00:09:31,070 --> 00:09:31,340 do. 87 00:09:31,460 --> 00:09:34,160 For example, what function to call soul. 88 00:09:34,170 --> 00:09:35,420 We switch 89 00:09:38,000 --> 00:09:38,990 on the option 90 00:09:44,330 --> 00:09:50,360 defined cases for the search between received flag value, and this is the way you want to call decline 91 00:09:50,380 --> 00:09:51,050 function. 92 00:09:51,200 --> 00:09:59,390 If the received value is client in concert or function, if the received value server so bride case 93 00:10:02,300 --> 00:10:03,230 clients 94 00:10:07,670 --> 00:10:18,470 calling RON function if Casey's client Ron Deoxy client and case. 95 00:10:21,380 --> 00:10:22,150 Sir. 96 00:10:25,190 --> 00:10:36,080 And calling several function of cases, server from geographies, etc. now we could define a flag and 97 00:10:36,080 --> 00:10:38,240 searches between return values. 98 00:10:38,540 --> 00:10:44,740 Now right client and server function, in order not to prolong the time of decision, we will finish 99 00:10:44,840 --> 00:10:47,780 it and we will continue the content in the next session. 100 00:10:47,960 --> 00:10:48,500 Goodbye.