Slide 1

Slide 1 text

Controle Remoto com NodeJS e WebSockets

Slide 2

Slide 2 text

Jaydson Gomes Entusiasta JavaScript Front­End engineer no Terra Curador do BrazilJS Curador do RSJS Fundador da BrazilJS Foundation E...

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Eugene J. Polley

Slide 7

Slide 7 text

Eugene J. Polley foi um engenheiro americano conhecido por inventar o Flash­Matic, um esboço do controle remoto para televisores

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Feixe de Luz

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

1955

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

||

Slide 19

Slide 19 text

Reinvente a roda!

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Não acredite em especialistas!

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Seja curioso!

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Node.js é uma plataforma construída com o V8 para criar aplicações rápidas e escaláveis. Node.js usa um modelo baseado em eventos, e I/O não bloqueante que permite que sejam criadas aplicações leves e eficientes, além de ser perfeito para sistemas com um volume grande da dados em real­ time.

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

WebSockets é uma tecnologia avançada que torna possível abrir uma sessão de comunicação interativa entre o browser e o servidor. Com essa API, tu pode enviar mensagens para um servidor e receber respostas baseadas em eventos sem consultar o servidor.

Slide 30

Slide 30 text

Can I use SVG? Compatibility table for support of SVG in desktop and mobile browsers. Legend Green Supported Red Not supported Greenish yellow Partially supported Gray Support unknown Web Sockets ­ Candidate Recommendation Global user stats*: Support: 69.11% Partial support: 0.94% Total: 70.05% IE Firefox Chrome Safari Opera iOS Safari Opera Mini Android Browser Blackberry Browser Opera Mobile Chrome for Android Firefox for Android IE Mobile 3 versions back 8.0: Not supported 27.0: Supported 32.0: Supported 5.1: Partial support 19.0: Supported 4.2­4.3: Partial support 4.0: Not supported 11.5: Partial support 2 versions back 9.0: Not supported 28.0: Supported 33.0: Supported 6.0: Supported 20.0: Supported 5.0­5.1: Partial support 4.1: Not supported 12.0: Partial support Previous version 10.0: Supported 29.0: Supported 34.0: Supported 6.1: Supported 21.0: Supported 6.0­6.1: Supported 4.2­4.3: Not supported 7.0: Supported 12.1: Supported Current 11.0: Supported 30.0: Supported 35.0: Supported 7.0: Supported 22.0: Supported 7.0­7.1: Supported 5.0­7.0: Not supported 4.4: Supported 10.0: Supported 22.0: Supported 35.0: Supported 30.0: Supported 10.0: Supported Near future 31.0: Supported 36.0: Supported 8.0: Supported 23.0: Supported 8.0: Supported 4.4.3: Supported

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

O objetivo do Socket.IO é tornar possível aplicações realtime em todos os browsers e dispositivos móveis, abstraindo as diferenças entre mecanismos de transporte. É realtime 100% em JavaScript, sem preocupações.

Slide 33

Slide 33 text

A fim de proporcionar conectividade realtime em todos os browsers, o Socket.IO seleciona qual o mecanimsmo de transporte disponível e capaz, em tempo de execução, sem afetar a API.

Slide 34

Slide 34 text

WebSocket Adobe® Flash® Socket AJAX long polling AJAX multipart streaming Forever Iframe JSONP Polling

Slide 35

Slide 35 text

SocketIO Server: v a r a p p = r e q u i r e ( ' h t t p ' ) . c r e a t e S e r v e r ( h a n d l e r ) , i o = r e q u i r e ( ' s o c k e t . i o ' ) . l i s t e n ( a p p ) , f s = r e q u i r e ( ' f s ' ) a p p . l i s t e n ( 8 0 ) ; f u n c t i o n h a n d l e r ( r e q , r e s ) { f s . r e a d F i l e ( _ _ d i r n a m e + ' / i n d e x . h t m l ' , f u n c t i o n ( e r r , d a t a ) { i f ( e r r ) { r e s . w r i t e H e a d ( 5 0 0 ) ; r e t u r n r e s . e n d ( ' E r r o r l o a d i n g i n d e x . h t m l ' ) ; } r e s . w r i t e H e a d ( 2 0 0 ) ; r e s . e n d ( d a t a ) ; } ) ; } i o . s o c k e t s . o n ( ' c o n n e c t i o n ' , f u n c t i o n ( s o c k e t ) { s o c k e t . e m i t ( ' n e w s ' , { h e l l o : ' w o r l d ' } ) ; s o c k e t . o n ( ' m y o t h e r e v e n t ' , f u n c t i o n ( d a t a ) { c o n s o l e . l o g ( d a t a ) ; } ) ; } ) ;

Slide 36

Slide 36 text

SocketIO Client: v a r s o c k e t = i o . c o n n e c t ( ' h t t p : / / l o c a l h o s t ' ) ; s o c k e t . o n ( ' n e w s ' , f u n c t i o n ( d a t a ) { c o n s o l e . l o g ( d a t a ) ; s o c k e t . e m i t ( ' m y o t h e r e v e n t ' , { m y : ' d a t a ' } ) ; } ) ;

Slide 37

Slide 37 text

Remote Control https://github.com/braziljs/remote­ control

Slide 38

Slide 38 text

v a r r e m o t e = n e w R e m o t e C o n t r o l ( ) ; r e m o t e . c o n n e c t ( ' h t t p : / / l o c a l h o s t : 8 1 ' ) ; r e m o t e . o n ( ' n e x t ' , f u n c t i o n ( ) { / / Y o u r m e t h o d t o m o v e t o t h e n e x t s l i d e } ) ; r e m o t e . o n ( ' p r e v i o u s ' , f u n c t i o n ( ) { / / Y o u r m e t h o d t o m o v e t o t h e p r e v i o u s s l i d e } ) ;

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

https://github.com/jaydson/remote­control­ eati­2012 http://jaydson.org/talks/remote­control­ eati­2012/

Slide 45

Slide 45 text

Obrigado! jaydson.org twitter.com/jaydson [email protected] github.com/jaydson