Tom Krcha's FlashRealtime

Hey amigo!
I am Tom Krcha, Gaming Evangelist at Adobe. These are my notes


Tip: Close Your Android AIR App on Back Button

October 13th, 2010

While developing AIR for Android apps, you should consider whether you need your apps to run in the background, especially if they are highly intensive graphic games.

To make your users even happier, it’s a good idea to close your app when the Back or Home button is pressed to free CPU and memory. Multitasking is a great thing, but if your app doesn’t need to be open, it’s better to close it and maybe save the state of your application. You can read this article on saving state in AIR applications for iOS devices (same should work for Android).

My fellow evangelist Mark Doherty sent me this code, which does the job. It can be helpful to you, so sharing:

Register handlers:

if(Capabilities.cpuArchitecture=="ARM")
{
	NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
	NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);
	NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
}

Define handlers:

private function handleActivate(event:Event):void
{
	NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}
 
private function handleDeactivate(event:Event):void
{
	NativeApplication.nativeApplication.exit();
}
 
private function handleKeys(event:KeyboardEvent):void
{
	if(event.keyCode == Keyboard.BACK)
	NativeApplication.nativeApplication.exit();
}

Good luck!

Local Flash Peer-to-Peer Communication over LAN (without Cirrus/Stratus)

August 27th, 2010

native-ip-multicast-small Some of you guys were probably wondering how to establish P2P connections in the local network (LAN) without Adobe Cirrus. Yes. It’s possible. Using native IP-only multicast. Let’s build a simple chat with Posting. Adding Multicast broadcast is just a simple next step which I am sure you can accomplish by yourself with few hints from my article about Multicast

Open an IP Multicast connection. This can be done by specifying connection string as “rtmpf:”. Note, that this technique cannot be used for one-to-one communication. So no DIRECT_CONNECTIONS with NetStream, but you can do all RTMFP Group operations.

netConnection.connect("rtmfp:");

Read the rest of this entry »

Video-on-Demand over P2P in Flash Player 10.1 with Object Replication

July 28th, 2010

In the previous tutorial File Sharing over P2P in Flash Player 10.1 with Object Replication we went through the Object Replication basics. And you can see that the Receiver is requesting packets one by one. That’s not suitable for the real world app, but it’s good for testing on a LAN to see the progress. In the real world app, you can immediately request all packets using NetGroup.addWantObjects(beginIndex, endIndex);.

Transferring VoD video over P2P

Let’s get something real with Object Replication. The use-case I like most is a Realtime P2P Distributed System for Video-on-Demand.
Video-on-Demand P2P Object Replication Scheme
Read the rest of this entry »

File Sharing over P2P in Flash Player 10.1 with Object Replication

July 14th, 2010

Read also: Video-on-Demand over P2P in Flash Player 10.1 with Object Replication

Object Replication

Object Replication is the most lowest-level P2P access available in Flash Player 10.1 (followed by Multicast, Posting and Directed Routing). It basically enables you to send chunks of data between peers. Object Replication is the only P2P access method that guarantees that all data will be transferred to all receiving peers.

Swarming

Demo

I’ve built this simple file sharing application, which basically loads a file and then you start sharing it. Open another client to start receiving the file.
provider-receiver-demo

Read the rest of this entry »

Multicast Explained in Flash 10.1 P2P

July 1st, 2010

Multicast is one of the features of Flash Player 10.1 and it enables you to distribute NetStreams across the peer-to-peer mesh. It can be audio, video or even pure data stream (AMF3) - the data stream can be very handy for games, it’s much better for such purpose (like sending realtime positions, directions) than using Posting as Posting is more optimized for large number of senders to send something - like chat, status change and so on.

Difference between Unicast and Multicast

Unicast
Unicast simply delivers streams from a server to n clients. For this purpose you can use Flash Media Server and TCP protocols such as RTMP/T/S/E or HTTP protocol. Unicast also costs you a lot of resources -> 1 MBps stream delivered to 1000 clients means 1 GB upstream from server - which is CPU demanding and network transit is also huge.
unicast2

Read the rest of this entry »