(1) Real Time Web. (2) Request – Response How would you create: A stock price ticker? A sports game cast app? A server status app? 1. Polling 2. Long.

Slides:



Advertisements
Similar presentations
IoT with SignalR & .NET Gadgeteer
Advertisements

@ScotHillier Web Parts Workflows Pages Libraries App Parts SharePoint-Hosted Apps Provider-Hosted Apps.
PHP syntax basics. Personal Home Page This is a Hypertext processor It works on the server side It demands a Web-server to be installed.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 11– Ajax Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
1/ November 2008 / EDS Internal Web Push Technology Dušan Chromý SOA Integration Consulting Reverse Ajax/Comet Explained.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Retrieving compound pages This work is licensed under a Creative Commons Attribution-Noncommercial- Share Alike 3.0 License. Skills: none IT concepts:
Hypertext Transfer Protocol Kyle Roth Mark Hoover.
INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
AJAX asynchronous server-client communication. Test.
Multiple Tiers in Action
Logins  You will need PHP to test this code, all modern web hosting companies will provide this, Lehigh does not.  I've given you an account on des170.com:
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Lightning Talk Fred Rodriguez Aakash Juneja CPSC 473 March 16, 2012.
Internet Applications Spring Review Last week –MySQL –Questions?
Ajax Application Errors Developer Oversight and Tracking Errors Presented by Eric Pascarello.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
Google Cloud Messaging for Android (GCM) is a free service that helps developers send data from servers to their Android.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
WEB WORKERS 1 Amitesh Madhur (Exceptional Performance, Bangalore)
Asterisk based real-time social chat Advisor : Lian-Jou Tsai Student : Jhe-Yu Wu.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Chapter 6: Authentications. Training Course, CS, NCTU 2 Overview  Getting Username and Password  Verifying Username and Password  Keeping The Verification.
Http protocol Response-request Clients not limited to web browsers. Anything that can access code implementing the protocol works: –Standalone programs.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
Zz SOCKET.IO going real time with Arnout Kazemier
Building a Web API for browser/JSON clients.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
Chat Room App Logan Linn Network Application Design Fall 2010.
Pushlets Introduce A comet framework Zhang Haipeng
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
ASP.NET SignalR SoftUni Team Technical Trainers Software University
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
ICM – API Server & Forms Gary Ratcliffe.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
Web Technologies Lecture 11 Implementing RESTful services.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
Client Side Requirement Unity3d game engine web plug-in Browser, Firefox, safari, IE, opera.
How Web Database Architectures Work CPS181s April 8, 2003.
Intro Web Applications Andrew Benson – ScottyLabs – CrashCourse F14.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏
Javascript AJAX HTML WEB SERVER Asynchronous. Javascript HTML events DOM – document object model browser internal view of html page compute.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
Developing for Chromecast Cast Companion Library & Custom Receiver Application.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
Research of Web Real-Time Communication Based on WebSocket
CS5220 Advanced Topics in Web Programming Introduction to WebSocket
Websocket Application
ASP.NET SignalR SoftUni Team C# MVC Frameworks Technical Trainers
Getting web pages First we need to get the webpage by issuing a HTTP request. The best option for this is the requests library that comes with Anaconda:
WebSocket: Full-Duplex Solution for the Web
Database Driven Websites
Web Systems Development (CSC-215)
Web Browser server client 3-Tier Architecture Apache web server PHP
HTTP/2.
JavaScript Form Validation
Web Socket Protocol.
Chengyu Sun California State University, Los Angeles
Client-Server Model: Requesting a Web Page
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Retrieving compound pages
Presentation transcript:

(1) Real Time Web

(2) Request – Response How would you create: A stock price ticker? A sports game cast app? A server status app? 1. Polling 2. Long polling

(3) Server-Sent Events Part of HTML 5 Efficient Server pushes data Events are handled directly by the browser Uses traditional HTTP

(4) Client side Uses JavaScript API EventSource EventSource.addEventListener(‘event’, function(event), false); - ‘message’, ‘open’, ‘error’ if (window.EventSource) { var source = new EventSource(‘sse.php’); } else { // use polling :( } source.addEventListener(‘message’, function(e) { console.log(e.data); }, false); source.addEventListener(‘open’, function(e) { // connection was opened }, false); source.addEventListener(‘error’, function(e) { if (e.readyState == EventSource.CLOSED) { // Connection was closed } }, false);

(5) Event Stream Format Plain text response with ‘text/event-stream’ Context-Type Basic format: data: The message\n\n Multiline format: data: first line\n data: second line\n\n

(6) Sending JSON Data Event Format data: {\n data: “msg”: “hello world”,\n data: “id”: 1234\n data: }\n\n source.addEventListener(‘message’, function(e) { var data = JSON.parse(e.data); console.log(data.id, data.msg); }, false);

(7) Event Ids Event Format: id: 54321\n data: Foo\n data: 435\n\n Browsers keep track of last event id If connection is dropped Send HTTP header with Last-Event-ID

(8) Reconnection Browsers will try to reconnect ~3 seconds Server can set that time using ‘retry: millisec’ retry: 10000\n data: hello world\n\n

(9) Event Name Event Stream: data: {“msg”: “First message”}\n\n event: userLogon\n data: {“username”: “Foo123”}\n\n event: update\n data: {“username”: “Foo123”, “emotion”: “happy”}\n\n source.addEventListener(‘message’, function(e) { var data = JSON.parse(e.data); console.log(data.id, data.msg); }, false); source.addEventListener(‘userLogon’, function(e) { var data = JSON.parse(e.data); console.log(‘User login: ‘ + data.username); }, false); source.addEventListener(‘update’, function(e) { var data = JSON.parse(e.data); console.log(data.username + ‘ is now ‘ + data.emotion); }, false);

(10) Server Side <?php header(‘Content-Type: text/event-stream’); header(‘Cache-Control: no-cache’); function sendMsg($id, $msg) { echo “id: $id”. PHP_EOL; echo “data: $msg”. PHP_EOL; echo PHP_EOL; ob_flush(); flush(); } $serverTime = time(); sendMsg($serverTime, ‘server time: ‘. date(“h:i:s”, time()));

(11) Client Side Cancel an Event Stream source.close(); Check the origin attribute of events source.addEventListener(‘message’, function(e) { if (e.origin != ‘ { alert(‘Origin was not localhost’); return; } var data = JSON.parse(e.data); console.log(data.id, data.msg); }, false);