The Hard Parts of Servers & Node.js Preparing for HTTPRequestObject
Transcript from the "Preparing for HTTPRequestObject" Lesson
>> Will Sentance: Node C++ features, there they are.
>> Will Sentance: There they are. But we don't just wanna do it in Node with C++, they're really only their choice so we can control?
>> Charlie: The computer.
>> Will Sentance: The computer's internals, exactly, thank you to Charlie.
[00:01:10] No pressure people but could call on any of you, at any moment. [LAUGH] Excellent. All right, Virginia. Line one, what are we doing, left hand side first, declaring what?
>> Virginia: A label called tweets?
>> Will Sentance: Beautiful. And the right hand side and yes, we are gonna go through each element.
[00:01:36] First element we're adding to the array is? next element we're adding to array is?
>> Virginia: Hi. Laughing face.
>> Will Sentance: Laugh, I love seeing what each person calls it, it's definitely laughing, crying emoji. Jenny was wrong. There you go, laughing, crying
>> Virginia: And a more formal hello.
>> Will Sentance: I don't know how to draw this.
>> Mohammed: [LAUGH]
>> Virginia: I mean you made your own slides, so.
>> Mohammed: [LAUGH]
>> Will Sentance: It's better than normal.
>> Mohammed: [LAUGH]
>> Will Sentance: Mohammed's got feedback on my art.
>> Mohammed: [LAUGH],
>> Will Sentance: You'd like to come, [LAUGH] All right. Okay, next one, yeah go ahead Virginia.
>> Virginia: The more formal hello.
>> Will Sentance: More formal hello, exactly.
[00:02:28] And then the next one?
>> Virginia: A waving hand?
>> Will Sentance: Hand waving emoji. So I'm gonna draw this one really well, no, that's, that's very creepy hand isn't it? Okay, I'll fix that. This is important material people. Okay, here we go. There it is, little hand waving emoji and the last one.
[00:02:49] Goodness, I can't draw this, is the snapchat the ghost emoji. It is.
>> Will Sentance: I should learn how to draw this, guys. There he is. I'm actually putting way more effort into this than normal. There he is, okay, we saved our Tweets, our data. Thank you very much, thank you everyone, no?
[00:03:10] No round of?
>> Will Sentance: Muted round of applause, did you put that in your annotations? More muted round of applause.
>> Virginia: Wasn't gonna clap?
[00:03:32] I have a feeling we might get it from somewhere else later on, we'll get to that. William, next line.
>> William: Then you're making a function definition called do on incoming,
>> Will Sentance: Do on incoming, how are we going to run this William?
>> William: Yeah.
>> Will Sentance: Are we developers ever gonna run this.
>> William: Are we going to know
>> Will Sentance: No. Definitely your first point yes exactly as well, but we don't win runs ourselves ever. We're instead going to tell no. Please run this, if you get inbound request. Perfect, all right. Next line, left hand side, Matt.
>> Matt: Next line would be we just did do it incoming, you were going into the function.
>> Will Sentance: We don't go inside a function until we do walk
>> William: Its the next line so server equals
>> Will Sentance: Excellent so to be clear. So how do we say the left hand side. There is a low quality technical communication Matt? How do we say the left hand side they're conserving sort of fancy technical communication anyone wants to give a shot?
>> Speaker 8: Label.
>> Will Sentance: Yeah.
>> Speaker 9: Define,
>> Will Sentance: The whole function definition does three thing.
[00:05:07] This http.create server does three things, two in Node.
>> Jeff: Jeff, yeah, so he's going to set up an incoming message in C++.
>> Will Sentance: Yeah, it's going to in C++ set here an instance of the HTTP feature which is really just a network connection, with that code having a C++ that's gonna happen in the computers tunnels.
[00:05:52] Where yeah, it's gonna set up an open channel to the internet, was there even challenge in the internet in networking Notes?
>> Speaker 8: Word.
>> Will Sentance: Not quite?
>> Speaker 9: Socket.
>> Will Sentance: Socket, exactly. Socket, perfect. Yeah, that's thing number one it does. Andrew, what's the next thing it does?
>> Andrew: Sets up some memory space for incoming data, and some member space forward the labor functions is set out going data.
>> Will Sentance: Not really until we get a message in, what's the next thing is gonna do? This is tough stuff. Virginia.
>> Virginia: Is gonna sup afrea to run the function doing the coming.
>> Will Sentance: Is going to take the dual incoming function and it's going to store to the autorun, when what happens?
[00:06:44] Raise your hand if you know what, yeah, Mohamed.
>> Mohammed: When you get an incoming message.
>> Will Sentance: When you get an incoming message, spot on. So let's grab the do and incoming function and throw it into node. Okay, autorun do on Incoming, yeah people. This is a complex paradigm, but by the end of it you're going to be bored of it, because it's always this for the rest of the Node.
>> Zep: Get a server object.
>> Will Sentance: That's an object which has a bunch of functions including listen and this function, all the functions that came out at that moment in that object are edit functions. To edit this background node C++ feature if we want to do well what do we want to edit Charlie?
>> Charlie: The port number.
>> Will Sentance: The port number. It doesn't default it would be nice, it would be easier for me to sort introduce this concept if it defaulted to a port, we have to set up our port. And that part we're gonna, so we're gonna use a lessen function which is linked so to Node.
[00:08:23] Is it really a node functions or node labels, labels for node features. And this one is a listen one, we're gonna grab the listen function and pause it, 80. Who wants to be the lucky person? Who wants to come up here and draw me a line in purple, for where this listen function is going to actually have its consequence?
[00:08:50] Michael my friend, up you come, you're the lucky to my favorite new interactive step. Give me a line were on the board it's going to have an effect, this server don't listen function. See you doing. Here.
>> Speaker 2: See, and there. Fantastic fantastic Thank you, Michael. The server not listen is having effect down in node, and it's setting what Charlie?
>> Will Sentance: Setting the port number.
>> Speaker 2: The port to 80, which is then doing that right here and opening up our entry point to our computer. And that little bit here, speaking to the underlying network, is done by C++ code, but it's a specific library of, it goes into node.
[00:09:35] What's the name of that library?
>> Will Sentance: Libuv.
>> Speaker 2: LibUV, there it is. Okay, well done everybody. Three things, one setup the actual HDP feature of node that sets up the open socket. Two, several function to auto run by passing it into create server, into node, in auto run if inbound message comes in, three.
[00:10:18] Excellent for Michael, very good of him to come up as well.