[00:00:25] How, via setting up a Node C++ feature. How, via a built in label http.createserver. Let's start to see what it does in action. Here we go. So, I'm gonna start actually here, with the right-hand side for once. Http.createserver parentheses. Okay, folk, point to me on the board, everybody point to me, on the board, where is that gonna have a consequence?
[00:01:29] Yeah, it's not that interesting, where it's really interesting is what it's gonna do in the computer's internals, with the help of libuv. Libuv is a bunch of pre written C++ code, technically built separately from Node, but its most prominent use is in Node, actually using lots of different libraries, but bunch of C++ code written to ensure that we can run Node, and we'll learn about how to run a little bit later on, on any machine, any operating system.
[00:01:56] Linux, Mac, Windows. Libuv links up effectively between C++ code written in Node with any computer internal structure, whether it's a Mac, Linux or Windows. Okay, so it's going to, with the help of Libuv, set up in the computer internals and open socket, an opened channel to the internet.
[00:02:24] Ready to receive HTTP messages and that`s it. That one line has opened. Our computer now Twitter's computer is now ready to receive messages. In one line, in one label. It opened that channel, in and out messages now, it is good to go. One issue, one issue. I actually, you know what I wanna do?
[00:02:51] There are actually 64,000, this is slightly metaphorical, there are actually 64,000 entry points to my computer. Now it's not literally what it actually is, is I can use 64,000 different numbers from 1 to 64,000 to represent, to indicate, or to mark off, an entry point into my computer.
[00:03:13] Not actually to carve out a little hole within the computer but I can give 64,000 different numbers to represent an entry point to chanel in my computer. Well, that's a bit of an issue, because when a say Rose sends out the message saying, hey, needing new Tweets, need Tweets, need the HTML, CSS, Tweets, images, etc.
[00:03:35] Which entry point is she gonna come in at? Anyone know what the default, they call them, not entry points, they call them ports. Anyone know what the default entry port is for any HTTP message being sent from a browser to a computer that receives messages known as a server.
[00:03:52] Anyone know the default entry point is? Yeah Mark.
>> Mark: 80.
>> Will Sentance: 80? It's 80. The entry point, it will default to be trying to arrive at, it's gonna try and arrive at Port 80. Well down, we already set up the background Node C++ feature. This instance of the HTTP feature of Node that set up this socket, how the hell do we continue to edit it and tell it actually you know what, specify the port to be 80.
>> Speaker 3: Server.
>> Will Sentance: Server, exactly, it immediately returns out into it, an object full of functions, methods, they call them when they're an object, methods, including ones like listen. All of which, when run, will allow us to edit the instance of the HTTP featuring Node that we've set up.
[00:05:14] Give us edit ability over it. And that's exactly what we're gonna have to use, because we need to tell Node, to tell the socket to set up to listen at, what point Michael? But what port sorry?
>> Michael: 80
>> Will Sentance: At 80. And we can do that because we can go and grab that listen function, that's we're gonna do on the next line, grab that listen function pass it 80.
[00:06:39] Super sophisticated. We do it in two lines. Okay, in comes the inbound message. Inbound, you know, incoming message from Sarah Rose. In comes, hey its unforgettable. All right there incomes a message, weee, will libuv, it lands in Node. But here's the problem folk, this message,
>> Will Sentance: We wanna look at it.
[00:07:06] See what it's asking for and send back the right tweets. Inbound by request, run code to look at it, you're gonna run code to look at introspect it, see what says. Something like this I guess. You wanna run some code like you know, if incoming message, then is pseudo code, then send back tweet data.
[00:08:32] So, whatever message comes in, it's running. His next line's gonna run. That means we can do one thing in our app. It's not a very good model. To be able to only receive one message and had to run the same line just in case the message comes in any moment.
>> Speaker 5: [LAUGH]
>> Will Sentance: So we don't do that. But that leaves us in a bit of a conundrum. Sam, who does know? We don't know. But who does know when an inbound message comes in?
>> Sam: Node knows.
>> Will Sentance: Node knows. That's great. Node knows. And so, perhaps, we're going to rely on Node to automatically run this line of code for us.
[00:09:17] Beyond that control. But how could we bundle up the code in order that it could be triggered to auto run by Node. How do we bundle up Mohammed?
>> Mohammed: Function.
>> Will Sentance: In a function. And that's what we're gonna do. People, again and again, we're gonna bundle up code in a function that we want to have auto run by Node to do stuff like look at incoming message, send tweet data back, when Node here is with the help of libuv that an inbound messages arrived.
[00:09:43] How people, but what about what moment with my favorite emoji. The woozy emoji. I, you know that emojis having a lot of a lot of fun. It's very, it's, if any one says this emoji, you know they're having a level of fun.