We launched a new IT training category! Check out the 140+ courses now.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating a Joomla! chatroom back-end

From: Node.js First Look

Video: Creating a Joomla! chatroom back-end

In the previous video, we added the front-end for our chat room in Joomla! Now let's add the back-end code so Joomla! users can talk to each other through the chat room. First, make sure you have at least two users in Joomla! I've added Joe and Tom both as users. Next, we're going to work with the server. I've copied the code from the exercise files, and it has a package.json file. Several dependencies are listed, so let's install them.

Creating a Joomla! chatroom back-end

In the previous video, we added the front-end for our chat room in Joomla! Now let's add the back-end code so Joomla! users can talk to each other through the chat room. First, make sure you have at least two users in Joomla! I've added Joe and Tom both as users. Next, we're going to work with the server. I've copied the code from the exercise files, and it has a package.json file. Several dependencies are listed, so let's install them.

After the modules are installed open up the server.js. In addition to the modules that we used in the original chat room, we're also loading the Joomla! module and the Cookie module, both of these modules are going to work together to authenticate users in Joomla! There are two options for configuring the Joomla! module. You can either pass in the full path to the Joomla! site, or you can pass in an object with the configuration values. I'm going to find the path to the Joomla! site and pass it in here.

The Joomla! module will automatically load your configuration.php file, run it and extract the configuration information. Once the configuration information is loaded, we log a message to the console, saying that the Joomla! site is ready. Now let's take a look at the function attached to the connection event. First, we're using cookie.parse to parse the cookies from the socket. Then we pass this object into the off cookies method of the Joomla! module.

Finally, this function returns the Joomla! user. If the username of the Joomla! user object is blank, that means the authentication failed. In this case we call the failure method of the chatter module. Otherwise, we connect the chatter to the chat room. We're passing in the username property of the Joomla! user object as the username. Let's start the server and start chatting. Now let's Refresh this page. The server responds saying, Please login to the chat room.

I'm going to login as Joe. Now that I've logged in as Joe the chat server sees my cookie, authenticates me, and then greets me by name. Now let's use a separate browser to login as Tom. It's important to use a separate browser, because this browser already has the cookie for Joe. I'm going to open up Safari. Again, we get a message saying, Please login to the chat room. Now that I've logged in as Tom, it shows me as online.

If I go back to the original chat room, I see the message that I just typed. The Joomla! module for Node allows you to connect to the database and authenticate users through cookies. Doing this allows you to associate the correct username with the socket. Once the server is running, users can log into Joomla! as they normally would, then talk to each other in the chat room.

Show transcript

This video is part of

Image for Node.js First Look
Node.js First Look

48 video lessons · 16955 viewers

Joseph LeBlanc
Author

 
Expand all | Collapse all
  1. 2m 40s
    1. Welcome
      37s
    2. What you need to know
      49s
    3. Using the exercise files
      1m 14s
  2. 11m 3s
    1. Understanding Node
      1m 21s
    2. Choosing an installation process
      1m 9s
    3. Installing Node on a Mac
      1m 43s
    4. Installing Node on a PC
      1m 42s
    5. Installing Node through a package manager
      1m 59s
    6. Compiling Node from source code
      3m 9s
  3. 9m 20s
    1. Running a Node script
      2m 6s
    2. Using the Read-Eval-Print-Loop (REPL) interface
      4m 49s
    3. Restarting scripts automatically
      2m 25s
  4. 10m 35s
    1. Understanding modules
      3m 39s
    2. Finding modules
      1m 59s
    3. Using modules
      2m 44s
    4. Maintaining modules
      2m 13s
  5. 9m 41s
    1. Reading arguments
      2m 34s
    2. Gathering user input
      1m 56s
    3. Selecting through browserless jQuery
      2m 36s
    4. Validating JavaScript code
      2m 35s
  6. 13m 55s
    1. Responding to requests
      4m 18s
    2. Using Connect
      3m 22s
    3. Reading request data
      2m 44s
    4. Sending different response types
      3m 31s
  7. 26m 56s
    1. Starting an Express project
      2m 58s
    2. Laying out views
      4m 47s
    3. Listing records
      3m 15s
    4. Filtering data
      3m 43s
    5. Getting organized
      2m 34s
    6. Posting data
      3m 36s
    7. Generating Express sites
      6m 3s
  8. 21m 23s
    1. What are WebSockets?
      2m 27s
    2. Installing Socket.IO
      3m 14s
    3. Emitting and receiving events
      2m 36s
    4. Communicating with individual sockets
      2m 17s
    5. Messaging across sockets
      2m 3s
    6. Implementing chat interfaces
      2m 56s
    7. Handling event types
      2m 10s
    8. Reusing chatrooms
      3m 40s
  9. 20m 0s
    1. Exploring integration options
      2m 4s
    2. Creating a WordPress chatroom front-end
      2m 29s
    3. Creating a WordPress chatroom back-end
      4m 6s
    4. Creating a Drupal chatroom front-end
      2m 18s
    5. Creating a Drupal chatroom back-end
      3m 20s
    6. Creating a Joomla! chatroom front-end
      2m 38s
    7. Creating a Joomla! chatroom back-end
      3m 5s
  10. 4m 52s
    1. Hosting Node projects
      3m 29s
    2. Next steps
      1m 23s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Node.js First Look.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.