Deno WebSockets Tutorial #1 - Introduction

Net Ninja · Beginner ·🌐 Frontend Engineering ·6y ago

Key Takeaways

Introduces WebSockets and their use with Deno for simple web chat room

Full Transcript

hey gang and welcome to this dino series where we're going to make a chatroom with WebSockets and Dino now just really quickly before we start the tutorial for those of you who want to support the channel and join the gang officially you can do by clicking that join button right here he's just at $0.99 or pence per month and you get these cool little ninja loyalty badges next to your name in the comments down below when you leave a comment you can also join by clicking the button right beneath the video if you're watching one now which I'm guessing you are it does exactly the same thing all right so now that's at the way let's get on with the tutorial alright then so first things first what our WebSockets well basically WebSockets are a way to connect a browser to a server and then allow bi-directional communication between them now it also allows for real-time data flow between the browser and the server as well without refreshing the page now bi-directional just means that data can flow in both ways so from the browser to the server and also from the server to the browser now I think the best way to explain this a bit more is by looking at an example so imagine we have a website ninja chat com which is going to be running on this server and this is going to host some kind of chatroom so when you use it in a browser goes to this website this server sends them a webpage back with a chatroom on it and then when the user gets this webpage in our code we tell the browser to set up a WebSocket connection with the server now once we have this WebSocket connection we can make use of real time data flow between the browser and the server so the browser can send data to the server and the server can send data to the browser and this can happen over and over in real time without the need to ever refresh the browser now imagine that all the users around the world also go to this website as well they get the same webpage back and each time their browser sets up a web socket connection with the server so now all browsers are connected via their own web socket to the server and now data can pass from each browser to the server and from the server to each browser so in the chatroom over here for example maybe someone types a message and hits send so it sends that data to the server via the WebSocket now our server can accept this message data and then send it back out every clients through each clients web socket with the server and then every browser is going to receive that data and show the message in that chatroom and this kind of data flow is going to apply for every message sent by whatever user sends it in whatever browser now it's not just chat rooms we use WebSockets for throughout other use cases as well for example sports websites which do live commentary and live browser updates maybe collaborative document editing sites like online coating platforms are even online drawing canvases with multiple users in this series we are going to be building a simple chat room where people can enter in their names and they can type messages to each other but also what you learn in this course can be applied to other types of websites which use web sockets as well now before you start this series I would highly recommend that you already have a basic understanding of Deno because I'm not going to be going over all of the basics in this series now if you want to learn Deno from the ground up I've got a Dino jumpstart tutorial series on this channel so I'll leave the link to that down below and you should definitely check out that first of all then come back here I'm also going to be using typescript in this tutorial and if you want to learn more about that I've got a full typescript tutorial right here on YouTube as well so the link to that is also going to be down below however if you're proficient in JavaScript then I think you're going to have no problem following along with this tutorial item now I've also created course files for every single lesson in this series and the found on the Dino web sockets github repo now I've done a different branch for each different lesson because every lesson has different code so if you want to see the code for lesson 3 for example you go to the lesson 3 branch and you're going to see all of the different folders and files and the code in those files are right here and also I'm going to be using visual studio code as my text editor of choice you don't have to but if you want to you can download it from code visual studio comm by clicking this button or right here so the first thing I'm gonna do is open up a project folder right here which I in fact already have done called Dino WebSockets and I just want to do some basic setup for this project so just create the files that we're going to need so the first thing to do is to create an apt ES file and this is going to be where all of our server code lives later on that we're going to run through Dino I'm also going to create a new folder called public which is going to be the folder that essentially is made public to the browser so anything like HTML files is going to go inside here speaking of those let's create an index.html file this is the file is gonna be served to the browser and it will eventually contain the chatroom on it for now all I'm going to do is say doc and then tap that creates me this mini HTML boilerplate and I'm going to change the title right here to ninja chat and then down here in the body I'm just going to do an h1 that also says ninja chats as well save that and in fact we'll just do two more things I'm going to add a style tag right here because in the next lesson we're going to create this template and we'll be adding styles and also at the bottom we want a script tag for any front-end JavaScript and it's going to interact with this page and also set up WebSockets on this page or later on as well so now we've got that sorted we're ready in the next lesson to dive in and create our Dino server or right here [Music]

Original Description

In this deno & websockets tutorial we'll disuss what websockets are * how we'll use them with deno to create a simple web chat room. 🐱‍👤🐱‍👤 JOIN THE GANG - https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg/join ---------------------------------------- 🐱‍💻 🐱‍💻 My Udemy Courses: + Modern JavaScript - https://www.thenetninja.co.uk/udemy/modern-javascript + Vue JS & Firebase - http://www.thenetninja.co.uk/udemy/vue-and-firebase + D3.js & Firebase - https://www.thenetninja.co.uk/udemy/d3-and-firebase 🐱‍💻 🐱‍💻 Course Files: https://github.com/iamshaunjp/deno-websockets 🐱‍💻 🐱‍💻 Other Related Free Courses: + TypeScript Tutorial - https://www.youtube.com/watch?v=2pZmKW9-I_k&list=PL4cUxeGkcC9gUgr39Q_yD6v-bSyMwKPUI + Deno Tutorial - https://www.youtube.com/watch?v=2iLeRzHvc10&list=PL4cUxeGkcC9gnaJdxuGvEGYQ9iHb8mxsh Get denon - https://deno.land/x/denon
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related AI Lessons

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →