Flutter WebRTC Video Calling Meeting App - Part1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back to snippet coder and we are back in our video and this is the first part of our web rtc meeting application with node.js and flutter so in this video we are going to write our node.js api so before starting the video if you are new to the channel subscribe the channel by clicking the subscribe button and click the bell icon to get notified about our latest videos thank you [Music] so first of all we have to add two packages in our node.js api and the first one is the mongos and this package we are going to use for storing our meeting detail and meeting users and the second package which we are going to use is the socket.io and this will be used as a signaling server in our node.js application reflector application for the communication of the webrtc signal and all so now let's move to the code part so here in the package.json file we have to add the packages and for adding the package we will open our terminal so here we have to run the command npm install mongos and it will add the package for the mongoose then same we have to do for our socket.i also and here we'll put npm install socket.io so here it will add the package so now here we will add that folder structure and all and the first folder we will create a config and we will add a new file here and name of the file is app.config.js file and here we have to add our mongodb connection and here we will create one variable constant underscore db underscore config is equal to and here we will put curly brackets and here we will put a db and here we have to put the path here mongodb colon slash slash localhost slash meeting hyphen app and she will put module dot exports is equal to curly brackets and he will put this db config [Music] so now we have to create the model files and for that also we have to create one folder here models and the first model file we are going to create here is meeting dot model dot js file and here we have to create constant mongoose is equal to require mongos it will get the object here then we will have constraint schema is equal to mongoose then here we have to create constant meeting is equal to start model and here we will get the schema here and we will put the name as a meeting this will be our table name or schema name you can say then we have mongos dot schema and here we have to create variables first one is a host id and this will be the id of the user which is going to host that meeting and here we will put type will be string then we have required true and this variable is required then we have host name and we will put here type string required true then we have the start time and the type will be date then we have the required true then here we have to create one more object that is meeting users and here we'll put meeting users and type will be in the ira format here we put curly brackets then the type will be mongoose dot schema dot types dot object id and the reference we will pick from our meeting user and that model will be create after this model and here we will put meeting user what it will do it will give us that array list for the all the meeting user which are in this particular meeting and we will get all the array then after that we have to do two json and we have to do some transformations transform function and here we have doc as a variable name you can put anything here we put red dot id that means whatever data we are returning here and the id we will replace it with our red dot underscore id dot tostring so what we are doing here we have just replaced our underscore id with the new variable in the json that is id and the value we are passing here the same that underscore id then we have to delete this variable red dot underscore id and we have to delete one more variable that is red dot double underscore v this will also come in the json and after that we can put that timestamp also timestamp true and after that we have to do module dot exports is equal to and we have to export this module that is meeting so what we did here we have just created one model file for the meeting with the schema we are including here host id host name then we have the start name then we have the meeting users here and that will be the array of the reference of this meeting user module and that model we will create now and here we have to create new file that is meeting hyphen user.model.js file and here we can just copy this model and we will paste here we will just replace the things here and here we will change it to meeting user this one also will change it to meeting user instead of host we will put here socket id type will be string and we will make it as optional here then we have the meeting id and that type will be this one that is schema dot object id and the reference will be our meeting model then we have our user id type will be string and we'll make it as a mandatory here same we will copy here and we will paste here and here we have one more that is joined type will be boolean and we will make it as a mandatory here then we have our name type will be string and we will make it as a mandatory same we will copy this one also and we will paste here we will change it to is a live and this one is not required and this two json is also not required we will remove from here and here we will change it to meeting user so what we did here we have created a model for our meeting user with that object containing socket id meeting id user id then we have the join variable that is a boolean type then we have the name type will be string then we have is alive and the type of boolean then we have the timestamp and here we are just exporting our meeting user so if you are watching this video as a new user to the node.js i have already covered all this basic of the mongodb with our node.js or stp and everything so if if you have not watched the video i will put the link in the description you can just watch the video to understand what we are doing because this video is a advanced topic of having the mongodb with our web rtc and on so let's proceed further and now we will get our service file [Music] here we have to create new folder that is services and here we have to create a new file here name will be meeting dot service dot js file so first of all we have to import our both the model file that is constant meeting is equal to require and we will put the path here dot dot slash model slash meeting dot model same we have to do for our meeting user also is equal to require then we have dot dot slash models slash meeting user model so now we have to create some function here the first one we are going to put here is the async function for the all to getting all that meeting user and all and we put here async function get all meeting users and here we have to pass two parameters first one is a meeting id then we have our callback and here we have to use meeting user model dot find and we have to pass here meeting id and we will pass here meet id this id as a variable and then we have a response and from here we will return callback null and response in the callback we have that first parameter as an error message then the second one has a data and we are passing a response as a data over there then we have our catch function and we will have error and from here we will return callback error so what we did here we are just calling a meeting user and we are calling here find function for getting all the meeting user on the basis of that meeting id then we are just in the response callback we are just passing the data what we are getting here in the cache we are just throwing the error here so now we have to get few more functions and then next one will be async function start meeting and here we have to pass that params then we have the callback here and here we have to get object here meeting user model is equal to new of meeting user and we have to pass this params here it will get the object for our model then we have to just call here meeting user model dot save then we have the response here and we have to put here async here response and from here we have to do one more thing and we have to so whatever that meeting user is getting add to the meeting we have to just update that meeting user to our meeting model also here if we go to our model file here you can see we have our meeting user array and we have to add a data here also whenever any new user add to the meeting then we have to add that user in this meeting model also so that we can have the updated array over there and for that we have to just put here await meeting dot find one and update and we have to pass our id and the id will be params dot meeting id then here we have to add the data here and we'll put here dollar sign add to set and here we will put meeting users and we have to pass this meeting user model so what does this add to set do basically it will add that value to the array existing array if that value is already over there it will do nothing over there then from here we will just return callback null then we have our response here then we have the catch function and here we have error error then from here we will return callback error so what we did here we have just created one function and the name of the function will be join meeting not that start meeting and start meeting function will be different this will be joint meeting and here what we are doing we are just created but model that is meeting user model there we are just creating that object with the meeting user model bypassing the params then we are just calling a save function and once we get the success then we are just adding this array this meeting user to our area of our meeting model also by calling this one that is find fun and update and then we are just returning a callback for the success and here we are just calling for the callback for our error and before that we have to also create one more function and name of the function is saying start meeting here we put async function and here we have params callback and here also we have constant meeting schema is equal to new of meeting params then from here we will call meeting schema dot save then we have then operator response and from here we will return callback null and we have response then from here we have cache function error from here we will return callback error so this will be useful by starting the meeting and when we click on the start button it will get the object in our meeting schema and it will add data over there so now let's move further and we will get few more function over there and the next one is our async function is meeting present and this function will be used for checking on the business of that meeting id if that meeting is valid or not by passing a meeting id then we have the callback here here we have to call meeting dot find by id and we have to pass this meeting id also we have to include our meeting user also over there and we have to put here meeting users then we have to map it with our model meeting user then we have to call here then response and we will check here if not of response then we have to call back here invalid meeting id in the else we will call here call back null true then we have the catch here and we'll put here error from here we will return callback error false so what we are doing here we are just checking here on the base of the meeting id if this meeting is valid or not if it is valid we are also just populating our meeting user array also with it and when we get a data over there with that data we are getting all that user also and if that meeting is not found we are just passing an invalid meeting id else we are just passing it data which we are getting from the database in the cache we are just throwing the error here so we have to create one more function in the similar but there we have to just pass selected column and we will change this name as a check meeting exist and here we have to pick view column only that is host id host name and start name and rest of the thing will be same so our next function will be async function get meeting user and here we have to pass params callback and from the firms we have to get meeting id user id is equal to params then from here we will call meeting user dot find and we have to pass a meeting id user id and on the basis of the response we are getting we are just pick only first response and we are just returning here call back null and we will put here response index 0 because we are only getting one data on the base of that meeting id and the user id then we have a catch here error we will return here callback error so we will now create one more function that function will be used for storing our socket id and all and you can say like updating the user details and we'll put here async function update meeting user and we will put here params callback and here we will call meeting user dot update 1 and will pass here user id params dot user id and we have to set here set params new true then here we have to check the response return callback null and here we are the response here catch we have to put here error from here we will return callback error so what we did here we are just updating our meeting user model by checking on the base of that user id and we are calling a update one it will update only one record on the pc of that user id and just we are just setting all the parameters what we are getting in that parameters data so now we have our last method that is async function get user by socket id and we will pass a params then we have the callback here and here we have constant meeting id socket id is equal to params then here we have to call meeting user dot fine here we have to pass meeting id and socket id and we will put a limit here one that is it will only fetch one record only because on the base of that meeting id and the socket id we only need one record then we have the response here is equal to and we will return a callback null response then we have the catch here we have the error and from here we will just return here callback error so what we are doing here we are just calling a meeting user and we are just calling a find and we are just limiting only one record then we are getting the response and here we are getting the catch error so now we have to export all our function which we have right here model dot exports is equal to start meeting then we have our join meeting then we have our get all meeting users then we have our is meeting present then we have our check meeting exists then we have work get user by socket id then we have our update meeting user then we have cat meeting user so all the function not going to use in our api we are just also we are going to use these function in our webs socket and all for checking our service so now let's move further with our controller file at all [Music] so now we have to create our controller file and for that we have to go to the folder structure and here we have to create controller and here we have to create a new file like this meeting dot controller dot js file here we have to write constant meeting services is equal to required and we have to import our meeting service file dot dot slash services slash meeting service and from here we will write first api that is exports dot start meeting is equal to required response next here we have to get that variables from our request body host id host name is equal to required dot body then here we will create a model where model is equal to host id and we will map it with our host id then we have host name we'll map it with our hostname then we have our start time and we will put here datetime now then from here we will call meeting services dot start meeting we will have model error then we have our results from here we will check if error then we will return here next error and here we have return response status 200 and we will send here message as success then we have data here that will be results dot id so what we are doing here we have created one function export dot start meeting then here we are just getting the host id and host name from our request body then here we are just creating one model with the host id host name and the start name then here we are just calling meeting services dot start meeting and here we are just passing the model then we are checking here for that if there will be any error we will go to the next else we are just sending the status at 200 with the messy as a success and data we are just passing a results dot id and this id will be our meeting id and that will be pass in our application now we will create next function and that will be used for validating our meeting id and all here we have exports dot check meeting exist is equal to request response next constant and we will pick the meeting id from our request dot query and this will be our query string and here we will call meeting services dot check meeting exist and we will pass here meeting id here we have error or results and we'll check it if error we will return here next error else we will return here response dot status 200 and we will send here send request with the message we will send here success then we have the data here and we will pass here results so what we are doing here we are we are just checking here if that meeting is exist or not by picking a meeting id from our query string then we are just calling a meeting services dot check meeting exists by passing our meeting id and here we are checking for the error and here we are just checking for the status 200 we are returning a status 200 so here we have to get one more function that is exports dot get all meeting users and we have request response next then from here we have constant meeting id is equal to request dot query then on the basis of that meeting id we will just call here meeting service dot get all meeting users and we'll pass a meeting id then we have error results and we have to check here if any error then from here we will call return next error else we will return here response dot status 200 dot send and the message we will pass here success then we have our data and we'll pass a results [Music] so our control file is also ready so now let's move further and we will get our routing file and all and for that we have to just create here new folder that is our routes here we have to create a new file that is app.routes.js file and here we have to import our meeting controller and we will write here constant meeting controller is equal to require and we will import the file here dot dot slash controllers controllers slash meeting controller then here we have to write constant express is equal to require and we have to import our express server here express then here we have constant a router is equal to express dot router if we write router taught post request slash meeting this will be the end point start and from here we will write meeting controller dot start meeting then we will have a router dot get request slash meeting slash join and here we will call meeting controller dot check meeting exists then we have router dot get request slash meeting slash get and this will be used for getting all the user inside that meeting meeting controller dot get all meeting users and from here we will call model dot exports is equal to router so our router file is also ready so we have added start and join function this one is optional if we have just added for testing also that our ap is working fine or not for that purpose also we can use it and here we are just doing the module dot export and so now let's move further and we will modify our index.js file also we have to create here index dot js here we have to first import constant express is equal to require express then we have constant app is equal to express then we have constant mongoose is equal to required mongoose then we have constant underscore db underscore config is equal to require dot slash config slash app config then here we have to write constant http is equal to require http then from here we have to get the server we have to put here server is equal to http dot create server and we'll pass here app and here later on we will get one file that is meeting iphone server and we will call here initialize meeting server and there we have to pass this server variable this one then here we have to write mongos dot promise is equal to global promise then we have to do the connection and all mongoose.connect and we have to pass here mongodb config and here we have to pass two variables use new url parser true and the second one is use unified topology true then from here we will get the response we will write a console.log [Music] database connected then here we have our error also we write here console.log database can't be connected and from here we will put app.use and we will pass here express dot json and from here we will call our routing and all app.use our output will be slash api and we will pass here require our route file dot slash route folder then we have app.routes from here we will just call your server dot listen process environment port number if we not get any we will just pass here default 4000 here we have function from here we will write console.log ready to go so our index.js file is also radius so now let's move further and now we will just set up our meeting server and that will be used for communicating the webrtc with our nodejs and our flutter application via our socket.io [Music] so now we will create one enum file and that enum file will contain all the command which we are going to send from our flutter application and to be read from our node.js application so for that we have to first create here one folder that is utils folder inside that we will get one file here and the name of the file will be meeting hyphen payload dot enum dot js file and here we have to create constant meeting payload enum is equal to and the first one will be join meeting and a command which we are going to send from our flutter application will be in this way join iphone meeting then we have second one joint meeting and it will be joined hyphen meeting all in lower case but the enum name will be in that upper case here we have user underscore join hyphen user hyphen join then we have connection underscore request here we have connection hyphen request then we will have incoming underscore connection underscore request incoming hyphen connection hyphen request then we have offer underscore sdp that is session description protocol and that terms which we have used in our introduction to webrtc and if you have not watched that video you can watch the video to understand what those terminologies are so here we have offer hyphen sdp then we have answer underscore sdp answer under iphone sdp then we have leave underscore meeting here we have leave hyphen meeting then we have and underscore meeting here we will put and hyphen meeting then we have user underscore left here we will put user hyphen left then we have meeting underscore end date here we will put meeting hyphen ended then we have ic candy date here we'll put ic candy date then we have video underscore toggle video hyphen toggle same we will do for the audio also we will put here audio toggle and here also we'll put audio toggle then we have not underscore found and here we put not hyphen found then we have last command that is unknown here we put unknown and from here we will do module dot exports is equal to meeting payload enum so what we did here we have just created one enum so instead of putting these command name over there we will just simply use our enum name like meeting play payload enum dot join meeting and joined meeting then we have user join connection request like this way we can do so now let's move further now we will get one helper file that is meeting helper file those will be having all the function of the command which we are going to use in our meeting server file and all here we will write meeting hyphen helper dot js file here we have to import two files that is constant meeting services is equal to required dot dot slash services slash meeting service then we have constant meeting payload enum is equal to required dot dot slash utils slash meeting payload dot enum so here we have to creates view function and the first one is going to have async function join meeting and this will be used when we handle our join meeting enum or you can say join meeting command which is coming from the flutter to our node.js then we will call this function here we have to pass meeting id then we have socket then we have payload then we have meetings server and these variable and parameter will be same for every function over there and here we'll put constant user id name and these data will come in our payload so suppose if we are calling this join meeting command from our flutter application to node.js via websocket there we are just sending a payload inside that payload we are just sending a user id and name and that will be calling in our join meeting then from here we will call meeting services dot is meeting present we'll call this function by passing this meeting id and we will check here if that meeting present or not then we have async error results and here we will check if error and not of results then we will send messages we have to create one function here and the function name will be function send message here we have socket socket as a parameter then we have payload and from here we will just call socket.send and from here we will pass our payload with our json dot stigmify and we'll pass a payload so from here we will just call this function send message and we will pass our socket here then from here we will just pass a type as a payload meeting payload enums dot not form and we are just sending the command to a flutter application via socket that is this this meeting not found else if we get any results over there then we have to create one function here add user and we will create that function here and name of the function will be function add user and we will have socket then we have meeting id user id then we have name here here we will use our promise promise is equal to new of promise because by calling this add user we have to do some other operation also so we have to wait till the time we get a result then only we can proceed further in that function for that purpose we are using here promise here we have function resolve reject from here we will call meeting services dot get meeting user and from here we will pass meeting id and user id then we will have error here and results and from here we will check if not of results then we will get here model that means this user not exists then we will just create a model here for adding the that user by putting a socket id as socket dot id and this will be the socket id of that particular user that will save in our database and then we will pass a meeting id and we'll map it with our meeting id parameter then we will have user id same with the user id then we have joined true name we will send here this one then we have is alive true then from here we will just call here meeting service dot join meeting and then here we will pass the parameter this model then from here we will get error or results so here we will check if we are having any results then we will put here resolve true that means success else if we are getting here any error we will put here reject and will pass here error message here we will put else condition if that user found then we have to just update our socket id of that particular user and here we'll put meeting services dot update meeting user and we'll just pass here user id and we'll map it with this user id then we have socket id we'll map it here with socket dot id then here we are getting error results here we check if results then resolve true else if we having error then we will reject here with that error message and from here we will just return promise so what we did here we have just created one function that is add user and here we are just passing socket then we are meeting id user id name then here we are just doing that promise and here we are just calling this get meeting user function by passing meeting id or user id and then we are checking here if that user already exists in that particular meeting or not if not exist then we will add that user through that particular meeting by calling this function meeting services dot join meeting else we will just update the socket id of that particular user by calling this update meeting user and from here we will just return promise and from here we will just call this function add user by passing here socket then we have meeting id then we have user id then we have name so instead of calling this whole code here we have just split the function in that separate function so that we can have the clean code over here then we have 10 here we have the result here we will check if result that means that user edit or update is successful then from here we will just send message with that socket we will pass here and the type will be meeting payload dot join meeting so this notification will be close to that user that meeting has been joined and here we will just pass that data here user id here we have to put curly brackets then from here we have to notify other users also that is someone joined that meeting except to that particular user which is joined a meeting so here also we have to create one small function and name the function will be function broadcast users and we have to pass a meeting id then we have socket then we have meeting server and here we have the payloads and from here we have to call socket dot broadcast dot emit and we have to omit this message and we have to pass json json.stignify and we have to pass this payload so what it will do it will just broadcast to all the user except to the currently added user and then all the other users get a notification like this particular user has been added to the meeting then we have to call this broadcast message from here and we have to pass here meeting id socket then we have meeting server the type will be meeting payload enums dot user join so this notification will because that is user has been joined and the data we are just passing here that user id then we have name then we have all the other payload which is it's having and here we have our error and we will just console right here this error message so what we did here we have just created one function for join meeting so this function will be called when user is going to join and here we are just checking if that mating present or not on the basis of that meeting id if that meeting is already present if that meeting is not present we will just throw the error here by putting by sending that notification via the socket that is not found then here we are just checking if that meeting found we will just add the user here inside that add user method we are just checking for user if that user exists or not if it it's not exist then we will add to the database else we will just update the socket id for that particular user then here on the success we are just sending the message for that join meeting then we are just broadcasting that message to the other users that is that user has been joined and here we are just doing that error console and all so next function which we have to create here is function forward connection request and here also we have to just pass our meeting id meeting id then we have socket then we have meeting server then we have payload here we have constant user id other user id then we have name then we have payload dot data so these information is coming when we are just sending this broadcast message and all then we are just getting all this information over there and just we are getting that payload data and from here we are just creating one model is equal to bypassing meeting id meeting id then we have user id and from here we are just passing this other user id because we have to send our connection request to the other user and for that we have to just get that socket id for that particular user and for getting that we have to just call here meeting services dot get meeting user and here we have to pass this model then we have error results then here we will check if results then we will send a payload here send payload is equal to json.stignify and we will just create here type and that will be meeting payload enum dot connection request and the data we are just passing a user id name dot dot payload dot data and from here we will just call here meeting server dot 2 and we will send this connection request to the other user on the basis of their socket id which we are getting from here by calling a results dot socket id dot emit message and here we will just pass the message here and we will send this payload data so what we are doing here we are just created one function forward connection request and that will be used when any user want to connect to the other user would want to join to the meeting then here we have just created one model with that meeting id and user id and on the basis of that we will just calling our cat meeting user from the mongodb and there we are just getting the result and that result will be used for our socket id then here we are just getting one payload that is sent payload and there we are just doing this json dot string define and a type we are just passing here meeting payload enum dot connection request and data we are just passing a user id name and a payload data then we are just sending this meeting server dot 2 that means that socket server is sending the request to that this user on the basis of their socket id and we are just passing this a message we are just calling this send payload by passing that connection request and all so next function will be the like similar and we have to just copy this one and we have to paste here and we will change it to forward i see candidate here also everything will be same just we have to change that meeting payload enum and we will change it to ic candidate rest everything will be same and here instead of name we will are getting a candidate then we have our next function that will also be similar and we have to just copy this function and we have to just paste here and name will be forward offer sdp here we are just getting user id or the user id and sdp as a payload and here we will just change it to offer sdp and here also instead of passing this name and payload we have to just change it to candidate in this function forward ic candidate we have to just change the data as a user id and candidate we have to pass in the send payload similar in this function also in the offer sdp we have to just pass a user id and sdp now again we have to copy this function with the next function and our next function forward answer sdp and here everything will be same user id or the userid sdp and here we have to just change the enum to answer sdp and rest everything will be same again we have to copy this function and we have to paste here and here we have to change the name as a user left and here we are just getting a user id and we don't need to check anything over here for that meeting username because this is the notification to send to everyone and we have to just call here broadcast function and we will call here broadcast user and we have to pass here meeting id then we have socket meeting server and type will be meeting payload enum dot user left and the data we are just passing here user id user id so what it will do this function will just broadcast to every user except to that particular user for if any user left a meeting then it will throw that notification for user left that particular user left same we have to copy again and we have to paste here and we will rename it as a and meeting here also everything will be same except this payload enum we have to change it to meeting and after throwing that broadcast user message we have to remove all that user from our socket also and for that we have to just call here meeting services dot get all meeting users and we have to pass here meeting id then we have error results and here we will put the loop for loop let i is equal to 0 i is less than results dot length i plus plus then here we will create one one variable constant meeting user is equal to results and will pass here i then we have to just call here meeting server dot sockets dot connected and we have to pass here circuit id on the basis of this meeting user variable dot socket id and we'll call it disconnect so what it will do we are just looping through our get all meeting user on the base of that meeting id and we are getting that meeting user object and we are just have to fetch our socket id and here we have to just check here if that user is connected on that basis of that socket id then we have to disconnect that user so here we have to again copy this function and we have to paste here and here we have to remove this code and here we have to rename it to forward even and this will be generic even will be used for our video toggle or you can say audio toggle so here we have to just instead of putting a meeting enum we have to just pass here payload dot type and here we have dot dot dot payload dot data so we have created all the functions so now we have to export those function with module dot exports is equal to where's the first function will be join meeting then we have forward connection request then we have forward ic candidate then we have forward offer sdp then we have forward answer stp then we have user left then we have end meeting then we have forward event so our meeting helper file is ready so now we will consume this file by creating a new file that is meeting server file so let's move further so now we will create a new file that is meetings iphone server dot js file and we will create it outside meeting iphone server dot js file and here first we have to import constraint meeting helper is equal to required dot slash utils slash meeting helper then we have to import our enum file meeting payload enum is equal to dot slash utils slash meeting payload tottenham here we have to create some function private functions function parse message and here we have to pass the message here and we'll put it right ha so that if we are getting any invalid message and all we are getting that error also in that case error handling will be done properly error and here we have constant payload is equal to json not pass so whatever the mess is coming we have to pass that message and from here we will return payload and from here we will return type meeting payloading dot unknown so next we have to create function listen message there we have to pass meeting id socket then we have meeting server and from here we will call socket dot on so when we get this in the socket this message from here we will pass message and we have to call the function which we will create here handle message and from here we will pass meeting id socket and meeting server so now here we have to create one function for handling the message handle message and here also we have to pass these information meeting id socket and that message and meeting server here we will create one variable payload is equal to empty and we will check here if the payload is coming as a data or as a json object and here we will put type of message is equal to string then we have to just call here payload is equal to parse message and we have to pass this message else we will just call here payload is equal to message that means we are getting the that payload in that object only then from here we have to just put your switch case payload dot type and here we check case and the first case will be meeting payload enum dot join meeting then we will call a meeting helper dot join meeting and we have to pass here meeting id socket payload and meeting server and here we will just break it so same we have to do for all the cases and the second one will be connection request here we have to change it to forward connection request rest everything will be same the next one will be our offer sdp offer sdp here we will change it to forward offer sdp here we have answer sdp and we will change it to forward answer sdp this one we will change it to leave meeting here also we will change it to user left then we have end meeting and this one will change it to and meeting function from the meeting helper and next one will be our video toggle same we have to do for the audio toggle also here we will just call forward event and rest everything will be same the last case will be our unknown if it will be unknown we will just break here and default also we will break here so what basically we are doing here we are just handling the message on the basis of that message so if you go to this function you can notice here if you go to our helper file also you have notice here we are just sending this broadcast message also and on the basis of that payload we are just checking here what type of request it is coming at is it a joint meeting connection request offer sdp answer sdp leave meeting and meeting and according to that we are just calling the helper metronome so instead of putting all those code here in this file so just to keep the code clean and maintainable we have just created one meeting helper file and there we have added all the function in the detail and here we are just doing the implementation and all so here we have to create one more function that will be the public function and meeting server and here we have to pass server here we have constant meeting server is equal to require socket dot io and here we have to pass this server then here we have to just call a meeting server dot on request connection and this is our socket connection we are doing here socket we will just get here meeting id also from our socket dot handshake dot query dot id then here in the listen message we have to just pass a meeting id socket and meeting server so what we did here we have just created one function initialize meeting server by passing this server and this function we have to call from our index.js file here we have just created the object for the meeting server on the base of that socket.io and we are just passing a server then we are just doing the connection on for our socket server then here we in the query sting of we are getting the meeting id from our flutter application then we are just calling a listen message and we are just passing a meeting id socket and a meeting server here and if we go to this function you can see here here we are just calling socket.on by calling here this message and this message we have to pass here after this socket and here we are just doing all the handling of the message and on the basis of that payload type and all we are just checking what type of payload is coming from the application request and then we are just according that calling the functions here so now we have to just call here module dot exports is equal to initialize meeting server so now we have to just go to index.js file and from here we have to just import it constant initialize meeting server is equal to require and we have to import here dot slash meeting server then we have to call here initialize meeting server and we have to pass this server here so it will just call this socket and all from here and we can remove this one so we can't do the testing of this api we have to just implement this one in our flutter application from there we will get the issues if any then we have to modify our node.js application so in the next video we will cover our flutter application by implementing this api over there so i hope you like the video don't forget to subscribe to the channel like comment share i will come back soon another awesome video thank you for watching the video [Music] you
Info
Channel: Snippet Coder
Views: 20,944
Rating: undefined out of 5
Keywords: webrtc, flutter video calling application, webrtc mobile application, whatsapp calling app clone in flutter, ms teams clone in flutter, skype clone in flutter, zoom meeting app clone in flutter, flutter video calling mobile app
Id: FZDCRza5UDQ
Channel Id: undefined
Length: 52min 13sec (3133 seconds)
Published: Tue May 31 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.