I haveourprojectfromthepreviousvideo, which, ifyouhaven't alreadyseen, makesuretocheckoutthecardsandthedescriptionfor a linktothat.
Butessentiallywhatwe'vedoneinthisvideoiswecanopenupourprojectusingliveserverandwecanrun a commandandPMrunDevstartandwe'regonnastartupourserveraswellasthestartofourapplication, andwecansendsomemessagesbackandforth.
Wecouldsaywhatournameis, forexample, andsendmessagesbackandforththatway, butweneedtodoinordertosetup a room.
Supportisweactuallyneedtoconvertourentireapplicationtousingexpressandeverythingwillruntotheconsolewhenwestartedourserverandwehavenoneedfor a lifeserver.
Sotodothat, what's closeoutofourconsulhereandweneedtorun a commandand P m i inordertoinstallourdependencies.
AndweneedtoinsultExpressaswellas E J s, whichwillbethetemplewaitinglanguagethatweuse.
Expressisgoingtoallowustomakeourserversetupreallyeasy, and e j s willallowustoembedservicesidecodeintoourtemplates.
Sowewanttocomeinhereandtypeinapdotsetandwewanttosetwhereourviewsweregoingtobecomingfromandourviewswerejustgoingtocomefrom a folderwhichisjustgoingtobecalledviews.
Everythingthatis a roomnamewillbepassedhereinanyroutethatis a slash, followedbyanynamewillgotothisrouteandagain, thisisgoingtotake a responseand a requestvariableinsideofourYouareoverouthereandwhatwewanttodoinhereiswejustwanttorenderanotherindexpage.
Andourcaseisjustgoingtobe a slashroomandwealsoneed a methodbecausethisisgoingtobe a postmethodsincewewanttocreatesomethingandpostisthewaytocreatethingswithhttp, Closeoffthatform.
Insideofthisform, it's gonnabereallysimple.
We'rejustgonnahave a singleinputwhichisgoingtohave a nameofroomandwe'regonnabeabletoaccessthisinputvariableonourformareonourserver.
Byusingthisnamehereofroom, you'llseethatit's a littlebitandwealsowanttomakesurethetypeofthisisequalthetextsinceit's just a textinputandlastly, we'regonnamakeitrequiredsothatit's requiredbytheactualHTMLtobesubmittedbeforewecansubmitourform.
Nowit's createdbuttonherewhereyou'regoingtohave a typeofsubmitsowecansubmitourformandwe'rejustgonnagetthetextofnewroomandlastly, closeoffthatbutton.
Butifwetriedtocreate a roomwiththeexactsamename, forexamplenew, weclicknewroom, youseethatitdoesn't getcreated, anditredirectsusbacktothispagesothatweknowthatweneedtocreate a roomwith a differentname.
So, forexample, wecouldjusttypein a randomnameupherefor a roomthatweknowdoesn't exist.
Andwhenwehitenter, it'llredirectusbacktothehomepagebecausewetriedtoaccess a roomthatdoesn't exist.
Butifweaccesstheroomthatdoesexist.
Asyoucansee, itallowsusthroughjustfine.
Nowwecanfinallyjumpintothefunpartofactuallydoingrealtimeintegration, sincewehavetheservercodedoneandtheeasiestfirstthingthatwecandoissendingthemessagetotheuserwhen a newroomiscreated.
Sowecanjustsaydot a tripisgoingtobeequaltoWe'regonnausestringinterpolation a slashfollowedbyourroomname, whichinourcase, isjustgoingtobethatroomvariable.
We'regonnadothesamethingfor a newuserjustlikethis.
ButthisroomnamedVariable, isnottofindanywhere.
Soweneedtoactuallytofindthat.
Andifyourememberinourservercodewerepassingtheroomnameddownindoor e Jsfile.
Soinsideofourroomdi e gsattheverytophere, aboveallofourdifferentscripts, we'rejustgoingtocreate a simplescripttagandinsideofthisscript, takewe'rejustgoingtocreate a variable, whichwe'rejustgonnacallroomname.
We'regonnauseour e j s inordertosetthisroomnameequaltotheroomNamethatourserverspassingdownsowecanuseourfancy E.
J s symbolsyntaxhereinordertoactuallyaccessthatbyusingthesepercentsymbolsandsuch, thisisgoingtoaccessourservervariableandsetitto a JavaScriptvariable, whichwecanuseontheclientside.
Sowhenweget a newuserhere, wehavesheneededfirstaccessourroomsvariablefor a specificroomandthengettheuser's forthatroomandaddthatusertothatroom's usersinsteadofjust a globallistofusersAgain.
Sowhatthisisgoingtodoisgoingtoconvertourobjecttoinarray, whichwecanuseinsideofthemethod, whichwe'regonnausethereducemethodforandreduces a slightlycomplexmethod.
Wewanttomakesuretoseeifwehave a userwiththatsocket I d.
Soifwedohave a userthatisnotequaltoknowherewewanttotakeournamesvariable, whichisgoingtobe a listofalloftheroomnameswewanttojustpushinthenameoftheroom, whichwehaverighthere.