Flash Camp Chennai - P2P with Flash Player 10.1

Post on 20-Jan-2015

1,149 views 2 download

Tags:

description

 

transcript

Peter Elst – Project CocoonP2P in Flash Player 10.1

Who am I?

Founding Partner – Project Cocoon Adobe Community Professional Adobe Certified Instructor Author "Object-Oriented ActionScript 3.0"

What is P2P? Technical walkthrough in Flash Player 10.1 Use cases for P2P and mobile devices Introducing Cocoon P2P Examples Questions & answers

What will we cover?

P2P lets devices directly communicate Clients connect once to a server, from there on data

goes between them Huge decrease in server bandwidth requirements You can do local P2P on the same network without

requiring any server (!)

What is P2P?

Centralized communication Single point of failure Bandwidth requirement increases per new client

connected Not extremely scalable

Traditional network

Decentralized communication More robust network setup Adding clients makes network faster Scalable solution for

multi-user applications

P2P network

Create a NetConnection instance Connect to RTMFP server instance Create a GroupSpecifier and NetGroup instance Setup NetGroup properties and permissions Listen for neighbor connect and disconnect events Post messages to the NetGroup or route it through

nearest neighbor Handle file chunks for object-replication ...

How does it work?

AIR for Android allows us to run desktop AIR files and take advantage of additional mobile specific features such as the accelerometer, geolocation,...

Almost - but not all - desktop APIs are supported Its a lot of fun to develop for!

AIR for Android

if(Accelerometer.isSupported){ var acc:Accelerometer = new Accelerometer(); acc.setRequestedUpdateInterval(500);  acc.addEventListener(AccelerometerEvent.UPDATE, update);}

private function update(evt:AccelerometerEvent):void { trace("x acceleration: "+evt.accelerationX); trace("y acceleration: "+evt.accelerationY); trace("z acceleration: "+evt.accelerationZ);}

Accelerometer

if(Geolocation.isSupported){ var geo:Geolocation = new Geolocation(); geo.setRequestedUpdateInterval(10000);  geo.addEventListener(GeolocationEvent.UPDATE, update);}

private function update(evt:GeolocationEvent):void { trace("latitude: "+evt.latitude); trace("longitude: "+evt.longitude); trace("speed: "+evt.speed);}

Geolocation

Packager for iPhone compiles AIR applicationsto native iOS binaries

Apple recently started allowing third party cross-compiled applications back into the app store

Compiled binaries generally have a larger file size

Packager for iPhone

Device turns into a universal game controller Data can be synchronized, stored on the device Single or multi-player, everyone carries a phone

so can join in

Use case: Games

Students can connect to a class whiteboard Solve problems individually or as a group Get real-time information on how students perform

Use case: E-Learning

Cocoon P2P

No need to get intimidated by the learning curve Cocoon P2P focuses on local network P2P Early support for file sharing (object-replication),

video streaming and accelerometer Incredibly easy to use

cocoon-p2p.googlecode.com (beta later this month)

Device Discovery

Device Discovery

<p2p:LocalNetworkDiscovery id="channel" />

<s:List dataProvider="{channel.clients}" labelField="clientName" />

Thats really all you need!

Chatroom

Chatroom

<p2p:LocalDeviceDiscovery id="discovery" clientAdded="onClientAdded(event)" clientRemoved="onClientRemoved(event)" dataReceived="onDataReceived(event)" loopback="true" />

Photo sharing

Photo sharing

<p2p:LocalDeviceDiscovery id="discovery" dataReceived="onDataReceived(event)" fileComplete="onFileComplete(event)" />

Multi-player game

Multi-player game

<p2p:LocalDeviceDiscovery id="discovery" accelerometerInterval="300" accelerometerUpdate="onAccelerate(event)" />

Video streaming

Video streaming

<p2p:LocalDeviceDiscovery id="discovery" videostream="{cam}" />

Does it require AIR?

Short answer, no! P2P is available as part of Flash Player 10.1 User can control whether to allow Peer-assisted

networking for a site AIR has a less restrictive sandbox to worry about

Summary

P2P support is available on all devices running Flash Player 10.1 or later

There is no server required between local devices on the same network

Mobile devices can be used as additional input or controllers for applications

27

Questions?

28

Thanks! நன்றி�! e-mail peter@project-cocoon.comwebsite www.project-cocoon.comblog www.peterelst.comtwitter @peterelst