WebSockets are a technology that allows developers to build highly interactive, extremely fast web applications. Since WebSockets are supported by all modern browsers, and have been for years now, there is no reason why they cannot be implemented on any modern web application. This course will show you how to work with WebSockets with Go.
WebSockets are a technology that allows developers to build highly interactive, extremely fast web applications. Since WebSockets are supported by all modern browsers, and have been for years now, there is no reason why they cannot be implemented on any modern web application. This course will show you how to work with WebSockets with Go.
We will work with two kinds of WebSocket technologies: first, with simple calls directly from our web application to all connected browsers, where all functionality is handled by our application. The web application we'll build is a simple chat application, which will allow users to chat back and forth, and will show the list of connected users, updated in real time.
Next, we'll take advantage of a Pusher compatible server (or Pusher itself, if you prefer) and use that server as a message broker between our web application and all connected clients.
I am a firm believer that learning how to use a particular technology works best when applying it to a real-world situation. All too often, tutorials and courses over simplify what they are trying to teach, and create an artificial environment where things are so simple that what is being taught looks easy enough, but you immediately run into problems when trying to implement it on a more complex project. So, to implement and learn about WebSockets and Pusher, we'll build a web application which monitors remote servers and hosts, and notifies us in real-time when a service goes down or comes back up again. We will send notifications in real time using WebSockets (which will update the appropriate content on the pages being viewed by all connected clients), by email, and, as a bonus, we'll also learn how to send notifications using text messages (SMS) with Twilio.
Who I am, and what we are going to do
How to install Go on Windows and a Mac
Setting up Visual Studio Code for Go
An overview of what we'll build in this section
How to build a very simple web application so we can get started
Writing Go code to upgrade a connection from http to ws
The basics of connecting to a websocket endpoint
Listening for different kinds of events
Listening for client actions in our application
Showing connected users in our chat application
Just fixing a minor problem
Another minor fix
Sending messages to all connected users
Some housekeeping issues with our code base
Installing the reconnecting websocket library
Giving visual feedback when a user connects to the chat application
Test your knowledge of using Javascript to work with websockets
An overview of the finished project
Installing some necessary software
Getting the starter code
Connecting to our Pusher compatible server
Sending an event from our application to the Pusher compatible server
Test your knowledge of connecting to a Pusher compatible server in Javascript
Getting our database ready for use
Setting up models to map our code to our database
Setting up HTML forms for managing hosts
Setting up our code to handle the host form
Passing the necessary data to the host form page
Writing the database method to save a new host to the database
Writing the database methods for getting and updating a host
Updating the host handler to accept updates
Listing all of our hosts in the web application
Getting started with adding services to our host
Improving our host services logic
Adding and removing host services in the database
Improving the way we list host services for the end user
Adding information to our overview page
Showing the status of all services on the overview page
Setting up the overview pages for services of a given status (healthy, pending, problem, and warning)
Some minor changes for the new version of Go
Setting up the service status tabs on the host page
Just a bit of clean up
Writing the code necessary to allow for manual checks of a given service
Finalizing the code necessary to allow for manual checks of a given service
Check your knowledge of sending an AJAX request using Javascript
Establishing a monitoring schedule that will run in the background
Just updating our chi router dependency
Continuing to write the code for the monitoring schedule
Finalizing the code for the monitoring schedule
Pushing websocket events when monitoring starts or stops
Running a local web server so that we have something to test against
How to run checks of external host services
Pushing websocket events to connected clients in real time
Updating the problem, pending, healthy and warning service counts in real time
Just a bit of housekeeping
Updating the host service status tables in real time
An overview of what the exercise entails
How I solved the exercise problem
Displaying the monitor schedule in a table
Changing the content of the schedule page in real time
Pushing websocket events when turning host services on and off
Ensuring that websocket events are pushed after a manual check
Displaying and saving a history of host service status changes
Just some housekeeping and code cleanup
Pushing a websocket event to a single user
Setting up Mailhog on a Mac for testing email services
Setting up Mailhog on Windows for testing email services
Sending email alerts when host service status changes
Overview of sending SMS messages with Twilio
Set up a developer account on Twilio
Optionally sending SMS alerts when a host service status changes
Getting started with monitoring SSL enabled web servers
Writing the code to monitor SSL enabled web servers
Monitoring SSL certificates on remote servers
A review of how to write tests for handlers
Writing tests that interact with pusher (or ipe)
Updating our test to remove the calls to an external service by mocking Pusher
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.