Slide 1

Slide 1 text

REACTING WITH Dallas PHP - October 2019

Slide 2

Slide 2 text

Reacting With Dallas PHP - August 2013

Slide 3

Slide 3 text

What do we need?

Slide 4

Slide 4 text

ASYNCHRONOUS

Slide 5

Slide 5 text

NON-BLOCKING

Slide 6

Slide 6 text

EVENT DRIVEN

Slide 7

Slide 7 text

INPUT / OUTPUT

Slide 8

Slide 8 text

ANBEDIO

Slide 9

Slide 9 text

Why do we need it?

Slide 10

Slide 10 text

● Queue Munching ● Real Time Communications ● File Transfers ● Timed Events

Slide 11

Slide 11 text

nodejs

Slide 12

Slide 12 text

nodejs (in the backend)

Slide 13

Slide 13 text

https://reactphp.org/

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

{ "require": { "react/react": "0.3.*" } } { "require": { "react/react": "^1.0" } }

Slide 16

Slide 16 text

The Event Loop

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

The Socket Server

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Socket Server: On Connection

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Socket Server: On Input

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Just because you received data, does not mean it is all your data. Example: Windows telnet sends every keypress as it happens. Unix telnet waits until new line.

Slide 28

Slide 28 text

Messages could get broken up into multiple packets and arrive to the client in the wrong order. That is how the internet works. As they arrive the NIC may choose to send you what it can construct properly *now* and wait until later to send the rest.

Slide 29

Slide 29 text

Buffers!

Slide 30

Slide 30 text

1 2 3 4 6 8 9 1 2 3 4 7

Slide 31

Slide 31 text

6 8 9 1 2 3 4 7 5 oh hai guiz 6 8 9 7 5

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Extending the Server

Slide 36

Slide 36 text

Extending the Server

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

WebSockets

Slide 41

Slide 41 text

have socket server? write javascript front end? will travel?

Slide 42

Slide 42 text

websocket: concept of awesome

Slide 43

Slide 43 text

websocket: implementation 2019 me thinks: still stupid

Slide 44

Slide 44 text

Ratchet To The Rescue http://socketo.me

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

• EventLoops • React\Socket\Server • connection, error • React\Socket\Connection • data, close, error • Ratchet\WsServer • Class implementing MessageComponentInterface • open, close, error, message

Slide 48

Slide 48 text

● Clients are basically the same as servers. ● Servers need to know how to handle: connections, data inputs, disconnections. ● Clients need to know how to handle: data inputs, disconnections. ● Both need to be able to: send data to the other.

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

so we can long herp our slow derps during all the things?

Slide 51

Slide 51 text

ANBEDIO

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

board members workers manager

Slide 54

Slide 54 text

WEBSITE: i need this report SERVER: ok, come back later. WEBSITE: ok thanks. SERVER: you there, you are not doing anything. generate this report. WORKER1: ok i’m off to work on it. bbl. // 30 min later WORKER1: all done. website can view it whenever. SERVER: ok thanks. i’ll email that bloke.

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

2013 vs 2019

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

Bob Majdak Jr twitter.com/bobmagicii [email protected] https://reactphp.org http://socketo.me