From the course: Web Servers and APIs using C++
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Reviewing the JavaScript client code - C++ Tutorial
From the course: Web Servers and APIs using C++
Reviewing the JavaScript client code
- [Instructor] The JavaScript file, websocket.js and its associated webpage, chat.html are both stored in the root directory for chapter six. Copy the JavaScript file to Public Scripts, so we're gonna do a Command + C to copy it, gonna go to Hello Crow, go to public, go to scripts, and do a Command + V, and we'll go back, copy the chat.html, Command + C, go to the public folder and do a Command + V, now we have both of those files. Let's go ahead and go back to Atom, open up websocket.js. Web Socket is a communication protocol which enables real-time data transfer between a client and server over a single TCP channel. Web Socket uses both the WS and WSS protocols for Web Socket and Web Socket Secured. Crow supports both protocols. In order to use Web Socket in the browser, we will need a client written in JavaScript. Don't worry, it's less than 40 lines of code. The first line of our client websocket.js creates the URL to the server's Web Socket implementation, so we are getting the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.