Red5 Authentication

May 7th, 2012 by Paul Gregoire

How to implement CRAM authentication in Red5

In this post we will setup a challenge-response authentication mechanism (CRAM) in a Red5 application using two different methods; the first one being very simple and the other utilizing the powerful Spring security libraries. A basic challenge-response process works like so:

  • Client requests a session
  • Server generates a unique, random ChallengeString (e.g. salt, guid) as well as a SessionID and sends both to client
  • Client gets UserID and Password from UI. Hashes the password once and call it PasswordHash. Then combines PasswordHash with the random string received from server in step 2, and hashes them together again, call this ResponseString
  • Client sends the server UserID, ResponseString and SessionID
  • Server looks up users stored PasswordHash based on UserID, and the original ChallengeString based on SessionID. Then computes the ResponseHash by hashing the PasswordHash and ChallengeString. If its equal to the ResponseString sent by user, then authentication succeeds.

Before we proceed further, it is assumed that you are somewhat familiar with Red5 applications and the Flex SDK. For those who would like a quick set of screencasts to get up-to-speed, we offer the following:

Implementation

Implementing a security mechanism is as simple as adding an application lifecycle listener to your application. Red5 supports a couple types of CRAM authentication via an available auth plugin. The first one implements the FMS authentication routine and the other one is a custom routine developed by the Red5 team. In this post we will use the Red5 routine. An ApplicationLifecycle class implementing the Red5 routine, may be found in the Red5 source repository; this code only validates against the password “test”. While this class would not be useful in production, it may certainly be used as a starting point for a real implementation. Red5AuthenticationHandler Source

To enable the usage of your Red5AuthenticationHandler class or any other ApplicationLifecycle type class for that matter, you must add it to the listeners in your Application’s appStart method.

The reason for putting it in the appStart method is to ensure that the handler is added when your application starts and before it starts accepting connections. There is no other code to add to your application adapter at this point since the lifecycle methods will fire in your handler. Putting the authentication code within a lifecycle handler serves to keep the adapter code cleaner and less confusing. The authentication handler is defined in the red5-web.xml like so:


At this point, your application would require authentication before a connection would be allowed to proceed beyond “connect”. Entering any user name and the password of “test” or “password” (depends on class used in demo) would allow a client to be connected. As stated previously, this first “simple” implementation is not meant for production but is offered as a means to understand the mechanism at work.

Adding Spring Security

Once we add security layers such as Spring security, the application and authentication features become much more robust. The first thing we must do is to add the Spring Security namespace to our applications red5-web.xml.

Replace this node:

With this node:


Add the authentication manager bean and configure it to use a plain text file. The users file contains our users, passwords, and their credentials.

To demonstrate how users are handled, we will create three users: 1 admin, 1 regular user, and 1 user without a role. The plain text users file follows this pattern: username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] A user can have more than one role specified; granted authority and role are synonymous. Below are the contents of our users file for this demo.


In addition to the authentication handler, a authentication manager must be added when using Spring security. The manager should be added to the appStart method prior to adding the handler, as shown below.

The Spring security version of the authentication handler will replace the simple version in your red5-web.xml like so:


Lastly, an aggregated user details service is used for storage and look ups of user details; this is essentially an interface to the internal in-memory datastore holding the user details or credentials. The user details may be configured to retrieve details from our local properties file, databases, ldap, or active directory. Our aggregated service is fairly simple as you can see below.

It should be noted that Spring security makes use of an additional Spring framework library that is not included in Red5; the transaction library provides DAO and transaction implementations which do not require an external database or related dependencies. All the libraries required for the demo are included in the project zip file.

Client code

Creation of an authentication enabled client will require a single library not included in Flex / Flash builder called as3crypto. The AS3 cryptography library will provide the hashing functions nessasary for authentication in our demo. Download the as3crypto.swc from: http://code.google.com/p/as3crypto/ and place it in the “libs” folder of our client project.

The following functions will be needed in your client support authentication:

The sendCreds method is called “later” from the sendCredentials method to prevent issues in the event thread.

These are the imports that need to be added before beginning.

In your connect function you will need to determine which authentication mode to employ. The following block will show how to set up the connect call based on the type selected.

You may notice that the type is simply a string in the url denoting which mode to use.

In your net status event handler, you will need to add handling for authentication routines. The following block demonstrates how to do so when an NetConnection.Connect.Rejected is received.

Once you are successfully connected, there are two methods in the demo code for testing access. The helloAdmin method will return a positive result if the authenticated user has the admin permission. In the helloUser method the routine is similar, but only the user permission is required. The included users file contains an admin user and two regular users, the second user is set up to have no permissions. The user without permissions may only connect application and call unprotected methods.

Protected methods in the application contain an isAuthorized check against preselected permissions.

If the user does not qualify, the call fails.

In a future post, I will explain how to add Java Authentication and Authorization Service (JAAS) to Red5.

Download
Project Source Client and server

, , , , , , , , , ,

Our First International Intern – Frederick Jansen Speaks Up

March 16th, 2012 by admin

We are pleased to have Frederick Jansen start this month as our first international intern. To start off his internship with us, we had him sit down and answer a couple of questions. As a student at the Interactive Multimedia Design at Lessius Mechelen situated in the quaint country of Belgium, Frederick focuses on anything and everything related to multimedia. In his own words, “Imagine a mix of design, development and the odd course focusing on business side of things, and you will have a pretty accurate view of what I do on a day to day basis”. He will be spending the next three months with us and we look forward to working with him.

1. Why did you choose Infrared5 as the place to do your internship?
Infrared5 was really my first and only choice. I met Chris Allen at FITC in Amsterdam when he was showing off their highly impressive Star Wars game along with Brass Monkey. Though my internship would not take place in at least another year, I figured it would not hurt to inquire about the option of training there. We kept in touch and things just followed (with some minor detours) from there on out.

2. What are the key things you hope to take away from this experience?
According to the US Bureau of Educational & Cultural Affairs, my visa is meant for: “[...] promoting mutual understanding between the people of the United States and the people of other countries by educational and cultural exchanges.” That along with networking and hopefully having some of the ingenuity of people working here brush off on me.

3. What is your favorite programming language?
The first language that comes to mind is ActionScript 3.0 with the addition of Flex, for a couple of reasons. A major point is definitely that it is one of the few languages which give me a sense of mastery. I feel comfortable to work with these techs and I know what will be outputted to my screen before hitting the compile button. There is a great community with tons of reading material and code examples, which makes the language both accessible and more rich.
Even though it sometimes feels a bit dumbed down with regard to lower level programming and could definitely benefit from a faster JIT compiler, it is one of the few languages with which you can easily reach a massive audience in the way you envisioned.

4. What would be an ideal position for you post college?
Though my work experience is quite limited at the moment, I think consultancy would be where I want to end up. Working for various companies on challenging problems, which they cannot wrap their head around, keeps things fresh and you on your toes. Ideally, that would be combined with some traveling as an alternative to the 9-5 schedule.

5. What drove you to do a internship in the USA?
Most of my fellow students picked a local company for their internship, which to me seems convenient, safe and overall not very exciting. Belgium does have some creative agencies which stand out, but they all center around the Belgian (or even Flemish) market. When it comes to (web) development, the focus in general is even more on small projects for local businesses, working with a standard array of technologies.
I knew I wanted to go abroad for my internship and experience more, though it was not the USA in itself which grabbed my attention. The fact of the matter is just that this country happens to offer the most exciting opportunities when it comes to working with cutting edge technology. After all, where else do you see more start-ups than here?

6. How do you keep on top of new technology?
With technology, especially web related, evolving so fast, to me this is one of the hardest things to do. There are a couple of ways I try to keep track of it though.
The benefit of being a student and not having to worry about providing for a family gives me the opportunity to experiment to my heart’s content. For college projects, I try to explore the boundaries of what we are allowed to work with and what I can personally achieve. Much to the dismay of a lot of professors, there is probably a 50/50 chance that I fail miserably or end up with something I can proudly showcase. Either way, to me that is the best way to learn so I will keep it up for as long as I can.
Then there are perhaps some more “conventional” ways. Whenever I get the opportunity, I go to Adobe Usergroup Meetings and conferences to get a feel for what others are working on. This not only inspires me to experiment more myself, but also gives me an insight in new and upcoming technology. I work with a lot of unreleased software and technology and try to incorporate that in my daily workflow. Though not always ideal, it does provide me with the opportunity to always keep one step ahead of what is coming and influence the direction of technology I work with on a day to day basis.
Finally, I browse the programming section of reddit, read technology related news sites, subscribe to various blogs, follow people on twitter, receive a weekly newsletter with interesting projects people are working on and various other things.

Gaming Ouroboros at the Global Game Jam 2012

February 6th, 2012 by Elliott Mitchell

Now and then, as a professional 3D technical artist and game designer, I find it’s helpful to step out of my usual routine and make a game over a weekend. Why? Because it keeps life fresh and exciting while providing a rare sense of instant gratification in the crazy world of video game development. Making a video game over a weekend isn’t easy for one person alone. For this, Global Game Jam was created.

This year’s Global Game Jam was held last January 27 – 29, 2012. I registered with was the Singapore-MIT GAMBIT Game Lab, in Cambridge, Massachusetts. Here is the lowdown of my experience.

Global Game Jam 2012 - Photo Courtesy Michael Carriere

The Global Game Jam (GGJ) is an annual International Game Developer Association (IGDA) game creation event. The event unites people from across the globe to make games in under 48 hours. Anyone is welcome to participate in the game jam. Jammers range from industry professionals to hobbyists and students. The primary framework is that under common constraints, each team completes a game, without preconceived ideas or preformed teams, in under 48 hours. This is intended to encourage creativity, experimentation and collaboration resulting in small but innovative games. To support this endeavor, schools, businesses and organizations volunteer to serve as official host sites. Several prominent sponsors such as Loot Drop, Autodesk, Microsoft and Brass Monkey also helped foot the bill.

HOW IT WENT DOWN

Keynote -

Brenda Brathwaite and John Romero addressing the Global Game Jammers 2012 - Photo courtesy Michael Carriere

GGJ site facilitators kicked off the Jam with a pre-recorded video from the IGDA website titled How to Build A Game in Less Than 48 Hours. The speakers in the video were Gordon Bellamy, the  Executive Director of the IGDA, John Romero (Quake) and Brenda Brathwaite (Wizardry) both co-founders of Loot Drop, Gonzalo Frasca (Ludology.org) the co-founder of Powerful Robot Games and Will Wright (The Simms) co-founder of Maxis. They speakers all gave excellent advice on creativity, leadership, scope and collaboration within a game jam.

Global Constraint -

Ouroboros

Our primary constraint was revealed after the keynote video. It was an image of a snake eating it’s own tail. The snake represented Ouroboros, a Greek mythological immortal. Variations of the symbol span across time and space from the modern day back to antiquity. The snake, or dragon in some instances, while eating it’s own tail has made appearances in ancient Egypt, Greece, India, Mexico, West Africa, Europe, South America and elsewhere under a host of names. It’s meaning can be interpreted as opposites merging in an a unifying act of cyclical creation and destruction, immortal for eternity. To alchemists the Ouroboros symbolized the Philosopher’s Stone.

Group Brainstorming –

Brainstorming Global Game Jam 2012

After the keynote game jammers arbitrarily split into 5 or 6 groups of 11 or so and went into different labs to brainstorm Ouroboros game pitches. After an amusing ricochet of thoughts, references, revisions, personalities and passions each room crafted 6 pitches which were mostly within the scope of the 48 hour Game Jam.

Pitch and Choose -

When the groups reassembled into the main room it was time to pitch.

The Rules-

  • Pitches needed to be under a minute
  • Title is 3 words or less
  • Theme related to the Ouroboros
  • The person pitching a game did not necessarily need to be on that potential team

There were about 30 or so pitches, after which each jammer had to choose a role on a game / team that appealed to them. Each Jammer had a single piece of colored coded paper with their name, skill level and intended role.

The Roles-

Choose Your Team - Global Game Jam 2012- Photo courtesy Michael Carriere

  • Programmer
  • Artist
  • Game Design
  • Audio
  • Producer

Games with too many team members were pruned and others lacking members for roles such as programmer were either augmented or eliminated. Eventually semi-balanced teams of 4-6 members were formed around the 11 most popular pitches.

My team decided to develop our game for the Commodore 64 computer using Ethan Fenn’s Comma8 framework. We thought the game narrative and technology married well.

Time to Jam - Photo Courtesy Michael Carriere

Time to Jam -

Post team formation, clusters of lab space were claimed. Even though most of us also brought our personal laptops, the labs were stocked with sweet dual boot Windows 7 & OS X systems with cinema displays. The lab computers were pre-installed with industry standard software such as Unity3d, Maya, Photoshop… We were also provided peripherals such as stylus tablets and keyboards. Ironically, I was most excited by the real world prototyping materials like blocks and graph paper which were also provided by or host.

First Things First –

Our space at Global Game Jam 2012 at Singapore - MIT GAMBIT Game Lab

After claiming a lab with another awesome team we immediately setup:

  • Version control (SVN)
  • Installed custom tools for Comma8 (Python, Java, Spite Pad, Tiles and more)
  • Confirmed the initial scope of the game
  • Set up collaborative project management system with a team Google Group and Google Doc

Cut That Out –

We needed to refine the scope once we were all aware of all the technical limitations such as:

  • Commodore 64 from 1982 is old
  • 64 kb of RAM for system not much
  • 8 bit
  • Programed in Assembly Language
  • 300 X 200 pixels
  • 16 pre-determined crappy colors
  • 3 Oscillators
  • Rectangular pixels
  • Screen Space
  • Developing in emulation on a network
  • Loading and testing a playable on legacy Commodore 64 hardware
  • Less than 48 hours to get it all working
  • Our scope was too big, too many levels
  • Other factors causing us to consider limiting the scope further included:
  • None of us had made games for C 64 before
  • Comma8 is an experimental engine that was untested in a game jam situation and is currently in development by Ethan
  • Tools such as Sprite Pad and Tiles are very archaic and limiting apps for art creation
  • Build process would do strange things to art after build time which required constant iteration

Rapid Iterative Prototyping -

Walking Backwards Prototype Global Game Jam 2012 - Photo Courtesy Michael Carriere

Physical prototyping was employed to reduce the scope before we went too far down any rabbit holes. We used the following materials to prototype:

  • Glass white board
  • Markers
  • Masking tape on the walls
  • Paper notes tacked to the walls
  • Graph paper
  • Wooden blocks
  • Pens

Results of Physical Prototyping-

  • Cut down scope from 9 levels to 5 levels as the minimum to carry the Ouroboros circular theme of our narrative far enough
  • Nailed the key mechanics
  • Refined the narrative
  • Determined scale and placement of graphical elements
  • Limited overall scope

Naturally we ran into design roadblocks and need to revise and adapt a few times. Physical prototyping once again sped up that process and move us along to completion.

QA-

Global Game Jam 2012 - Photo Courtesy Michael Carriere

We enlisted a few play testers on the second night and final hours of the game jam to help us gauge the following:

  • Playability
  • Comprehension of the narrative
  • Recognition of the lo-res art assets
  • Overall player experiences
  • Feelings about the game
  • Suggestions
  • Bugs

We did wind up having to revise the art, level design and narrative slightly to reach a better balance and game after play testing.

Deadline -

Walking Backwards - C64 - Global Game Jam 2012

1.5 hours before the game jam was to end it was pencilsdown. Time to upload to the IDGA Global Game Jam website, any other host servers and on to the site presentation computer. Out of the total 48 hours allotted to the game jam, we

only had about 25 working lab hours. Much time was spent on logistics like the keynote video, brainstorming, pitching, uploading and presenting. Our site also was only open from 9 am to midnight so there was not 24 hour access. With 25 hours of lab time all 11 games at my site were uploaded and ready for presentation.

Presentations -

Global Game Jam - Singapore-MIT GAMBIT Game Lab Games

The best part ever! The presentations were so exciting. Many of the jammers were so focused on their work they were not aware of what other teams were up to. One by one teams went up and presented their games in whatever the current game state was at the deadline.

Most were pretty innovative, experimental and funny. Titles such as The Ouroboros Hangover and Hoop Snake had the jammers in stitches. Fire farting dragons, Hoop Snakes, drunk Ouroboros and so on were big hits. Unity, HTML 5, Flash, Flex, XNA, Comma8 and Flixel were used to create the great games in under 48 hours.

Take Aways -

My teammates and I consider the game we made, Walking Backwards, to be a success.   We accomplished our goals:

Walking Backwards Team - Global Game Jam 2012- Photo courtesy Michael Carriere

  • Experimental game
  • A compelling narrative
  • Awesome audio composition
  • Most functionality we wanted we achieved
  • Runs on an original Commodore 64 with Joysticks
  • Can be played with a Java emulator
  • Got to work together under pressure and have a blast

Would have liked-

  • Avatar to animate properly (we had bi-directional sprites made but not implemented)
  • More audio for sound effects

The final take away I had, besides feeling simultaneously exhilarated and exhausted, is how essential networking at the game jam is for greater success. Beyond just meeting new people, networking at the jam made or broke some games. Some teams didn’t take time to walk around and talk to other teams. In one instance, a team didn’t figure out a essential ghost mechanic by the end of the jam. They realized at presentation time another team had implemented the same mechanic they failed to nail down in the same engine. Networking also provided mutual feedback, play testing, critique, advise, friendships and rounds of beer after the event ended. Many of the jammers now have a better sense of each other’s strengths and weaknesses, their performance under stress, their abilities to collaborate, lead and follow.

I, for one, will be a life long game jammer, ready to collaborate while pushing into both familiar and new territories of game development with various teams, themes and dreams.

Follow this link to see all the games created at my site hosted by the Singapore-MIT GAMBIT Game Labs

——

Elliott Mitchell

Technical Director- Infrared5

Twitter: @ Mrt3d

, , , , ,

Red5 Vector Support

August 3rd, 2011 by Paul Gregoire

It all started for me last year, I noticed Jean-Philippe Auclair blogged about reading AS3 Vector’s in Java and provided byte-level examples. Since the blogged examples were written in Java, I saw this as an invitation to implement them in Red5. I knew of Vector’s in Java but had no idea they had been implemented in actionscript and with what looked to me like generics. In AS3 the generic notation denotes the base type for each element in the Vector, which is also how it works in Java. The main differences between the implementations are that a Vector in AS3 is basically a faster version of Array and in Java it is a synchronized List-type collection. Similarly each element must be either “null” or an instance of the base type. Java is a lot more flexible with the instances in this case, because the element merely needs to implement or extend the base type. In AS3 handling is different, a Vector of DisplayObject type will not accept a Sprite instance.

Before I get down to the byte-level stuff, I want to note that this information may not be exactly correct in terms of what or how these items are constructed by the flash player; they are however the result of reverse engineering the data. Anyone with more information or a correction is welcome to send it my way.

The following examples show how the Vector is constructed in AS3 and then its representation in bytes. The byte arrays are encoded as big endian and are not compressed.

Vector with numbers and a string

A Vector containing two Number objects and a simple repeating string:

Trace:

Raw bytes:

Vector inside a Vector with other objects

A Vector containing the previous examples Vector in addition to another Vector of int type:

Trace:

Raw bytes:

Mixed Vector with class instance member

A Vector containing a simple String, a “null”, and the instance of a custom class:

Trace:

Raw bytes:

The “Foo3″ classes

Actionscript

Java

The original post does not contain details for writing back to Flash Player so I simply reversed the process once I had read working in the server. To test round-trip (deserialization/serialization), I used this method in my Red5 application:

The method accepts a Vector containing any type of object and returns it back to the client as a response. On the client you’ll need a pair of methods to both hit the server and to get the response.

Lastly, to use Vector’s with Red5 you will need the latest trunk with a revision of 4264 or newer.

For your reference, the AS3 doc page for Vector may be found here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html
Note: Vector’s are available to Flash Player starting with the version 10 beta.

, , , ,

Working with Native JSON in Flash Player 11

July 21st, 2011 by Todd Anderson

With the recent public release of the next candidates for the Flash Player and AIR runtimes, I wanted to check out one of the features that I had been waiting to see as part of the player for some time. No, not Molehill. Native JSON support! Boring, right? Maybe i’ll address Stage3D (née Molehill) in another article, but initially I am actually more curious to check out the native JSON support.

If you are unfamiliar with JSON, it is lightweight, interchangeable format that is human-readable and has a familiar structure that allows for ease in parsing and generating data. You can read more about it at http://www.json.org.

History… sorta

For applications targeting the Flash Platform, there was a time when you would typically go grab the as3corelib library and use the JSON class to encode or decode JSON data – actually, the time is still now, or until these runtimes are out of candidacy. Though the JSON class from the as3corelib library works well and was a welcome addition to the community, it sits outside of the player globals and is implemented in ActionScript. That’s not to say it is necessarily slow, but – because of its implementation – it is inherently slower than having native support of JSON within the player.

Future… kinda

With the advent of native JSON support in the Flash Player 11 and AIR 3 runtimes, we now are afforded serialization and deserialization at a faster speed as well as an API that matches that of the JavaScript implementation.

JSON API

You can head over to the online docs and check out the JSON API for a deeper explanation, but the JSON class basically has two static methods:

If coming from working with the JSON class from as3corelib, these will most likely look different than the methods you are used to. That’s alright, they do relatively the same thing and, depending on the level of control you want, it may just be a matter of the methods being named differently. I do want to go over what has been made available in these methods in moving toward the use of the native JSON class, however, as they can be quite interesting and possibly useful depending on the design of your application.

JSON.stringify()

The JSON.stringify() method does essentially what you may be familiar with as JSON.encode() from the as3corelib – put object in, get string out. However, the global JSON class of FP11 now has a couple more parameters that can be used to your advantage when turning that object into a JSON string.

The replacer parameter can be supplied as a list of String or Number that correspond to the key-value pairs which you want to serialize to a JSON string. It can also be supplied as a Function delegate that will be invoked upon each key-value pair that allows you to handle the data directly in either modifying the value being generated or – in the case of returning undefined – removing it from serialization.

Here is a quick example of how you can assign a replacer delegate and remove a value from being serialized to the generated JSON string:

That gives you a little peek at the potential that a replacer has when generating JSON, but you can imagine that it could be valuable for, say, hashing passwords and such on the client side before being sent over the wire.

The other parameter in JSON.stringify() – space – can be a String or Number and is used in prettifying the generated JSON string by providing whitespace and readability. Using the previous example, if we provided the value of 4 as the argument for spacer, the trace output would no longer be on one line and look more like this:

Pretty!

JSON.parse()

Let’s take a look at the parse method. Again, if coming from as3corelib JSON, it will probably just be a change of calling:

[FP 11 global: JSON]

instead of:

[as3corelib: JSON]

However, there is a reviver parameter on the parse() method which can be of use if you wish to handle working with the key-value pairs during the parse operation of the value object. The signature of the Function supplied as the reviver should have two parameters defined – key and value – and should return the modified value in order to be stored in the object.

Here is a quick example of using the parse() method with a reviver that turns each string value to upper case:

One thing to note here is that if you return undefined from the reviver delegate, you can actually remove the property and its value from the generated object, which is useful but also is something to look out for if things seem to be going wrong. Another thing to note here is that the last key-value pair passed through this reviver delegate is the actual object itself – keep that in mind when using a reviver and make sure to check that you are not modifying the whole object you are parsing.

Going a step further

Now this new API is well and good and we could be on our way sending and receiving JSON data and punch our time card and grab a beer, but there may come a time where you actually want to have more of a workflow in streamlining the generation and parsing of this data using real model objects in your project rather than generic Objects.

Now it is true that as long as the property values held on a custom object are those that are supported in the JSON format – string, number, boolean, array and null – that you could supply the custom object to the JSON.stringify() method and it will properly generate the JSON object for you. Going the other way – parsing – however, is not going to inherently create or write to that custom object that you may have previously serialized; it will just generate a generic object. Of course there is nothing stopping you from traversing the properties on that object and setting them on a new custom instance, but this is an opportunity in which we might want to think about how we can go about creating a design in which we can easily map back to custom objects. Things I like to think about and bore people with. Don’t fall asleep on me.

To get an idea of what i am talking about, say we have a Person class which serves as a model for a person in the context of our application. It has your basic properties on it which are standard value types – like name, company, etc from previous examples. We can certainly generate a JSON string and pass that around like so:

Now, in our perfect world, that would trace [object Person], wherein the JSON parser was knowledgable to map the object to a Person. There is that reviver parameter on JSON.parse() but that won’t help us much in mapping back to a custom instance as it only handles the key-value pairs and not the object as a whole.

One solution is to serialize the classname down with the generated JSON object, so that when it is received on the client, we can inflate a custom instance based on the associated class. So, if you can imagine, the models you will use in your application all extend a base model that handles setting this classname that is accessible and writable to a JSON object, eg:

In this base model class, there is a model accessor which is the qualified classname of the subclass. It also exposes a description accessor which allows easy access to the list of read-write properties on the subclass. It is marked as transient to denote that it should not be considered enumerable when generating the associated JSON object.

Now that we have our base model, any subclasses will be serialized with a model property representing the qualified clas name which can be used to inflate the custom object upon parse. Modifying the Person class used in a previous example, the class now looks like this:

We just have to remember to call super() in the constructor or ensure that the _clazz property value is that of the subclass. From here, all that is left is using that model property to instantiate a new instance and fill the available property values from the parsed JSON object received. Here is a quick working example:

In the parseToModel() method in this example, we see how the read-only model property is passed in the flash.utils.getDefinitionByName() function to inflate a new instance of the associated model – Person – that was previously serialized to a JSON object.

One thing to remember is that a reference to the class in which you want to use to inflate a new instance of must be compiled into the SWF, otherwise you will get Runtime Errors. There are a couple ways in which you can ensure that the reference is included, and I will leave that up to you to explore.

View and download the example

That is just one solution in implementing the ability to map JSON objects back to custom instances, but I am sure there are many more and I would like to hear your thoughts on them in the comments.

Conclusion

Native JSON support to the runtimes is a much welcomed addition and I am very happy to see it finally become a reality, and it is good to see – in my opinion – an API that matches that of the one on the JavaScript side. Hopefully I covered some of what can be accomplished with it and how it can benefit you in any current or future projects. Go grab the beta players, and the playerglobal SWC and have some fun!

, , ,

The Evolution of Infrared5

June 21st, 2011 by Keith Peters

I joined Infrared5 back in November 2007. Those were very different times. We were a hard core Flash shop, focusing on Red5 Server based applications and Papervision3D. The iPhone had been out for less than six months and only Apple could write apps for it. The iPod Touch was just a few weeks old. Nobody had heard of Android. Tablets were just a failed venture by Microsoft that most people had forgotten about a few years before. Nobody was particularly excited about HTML (5 or otherwise) or JavaScript. If there was any perceived threat to Flash at the time, it might have been Silverlight, but nobody was particularly worried about that.

Now, the landscape is very different. I’m not going to say Flash is dead. I don’t think it is. I don’t even think that it is dying, per se. What is happening though, is that there are so many other cool and interesting things out there now, that Flash has lost its place in the spotlight for many developers. Also, I think that Flash initially had a very low learning curve and very little barrier to entry. A lot of Flash developers grew up as Flash did, learned real programming, object orientation, design patterns, best practices, etc., and were then able to branch out to other languages and platforms.

I have to say, that Infrared5 has not only rolled with the changes very well, but has completely embraced the change. I think virtually all of our front end developers are now seasoned iOS developers. Several have embraced Android development as well. We have Windows Phone 7 knowledge (mostly me), and our 3D platform has moved from Papervision to Unity. We’re doing HTML5 stuff as well as Flash and Flex sites, iPad apps, kiosk applications. Many of our projects even span multiple platforms – a Flex 4 app with an HTML5 public facing site, Flash or Unity 3D games with a companion iPhone app via Brass Monkey.

The company’s tag line is “Yeah, we can build that.” I’d say we’ve lived up to that.

In closing, I ran across this quote the other day that I really loved. It comes from a free on line book, “Learn Python the Hard Way”, by Zed A. Shaw, which you can find here: http://learnpythonthehardway.org/ . In the last section called “Advice From An Old Programmer”, he says:

“What I discovered after this journey of learning is that the languages did not matter, it’s what you do with them. Actually, I always knew that, but I’d get distracted by the languages and forget it periodically. Now I never forget it, and neither should you.

Which programming language you learn and use does not matter. Do not get sucked into the religion surrounding programming languages as that will only blind you to their true purpose of being your tool for doing interesting things.

Programming as an intellectual activity is the only art form that allows you to create interactive art. You can create projects that other people can play with, and you can talk to them indirectly. No other art form is quite this interactive. Movies flow to the audience in one direction. Paintings do not move. Code goes both ways.”

The full quote is here: http://learnpythonthehardway.org/book/advice.html

, , , , , , ,

Infrared5 Joins ng Connect Program

January 5th, 2011 by Mike Oldham

Infrared5 Joins ng Connect Program to Enable High Definition Video Streaming Over Broadband Wireless Networks – Collaborates on Innovative Solution Concept for Retail, Travel, Tourism Industries

Boston, MA, January 5, 2011 – Infrared5™, a leader in web and mobile software development services, announced today that they have joined the ng Connect Program, a multi industry initiative founded by Alcatel-Lucent to drive innovation in services using next generation broadband technologies such as the Long Term Evolution (LTE).

Under the auspices of the ng Connect Program, Infrared5 was hired by lead collaborator MediaTile with support from Alcatel-Lucent to develop software components for the Virtual Concierge, a new solution concept announced today.  This next generation pedestal-type digital 2-way video interactive platform will transform the retail, travel, and tourism industries. MediaTile contracted Infrared5 to develop a combination of open source and proprietary technologies,  to enable high definition video to be streamed over a 4G/LTE network as part of the MediaCast Video Presence system. This infrastructure enables 2-way video chat from any location enabling customers to speak directly to a concierge that could be located anywhere else in the world and have an instant conversation remotely. The kiosk can operate over any broadband wireless network, specifically 4G/LTE, and therefore the device can literally be plugged in and run from anywhere.

Infrared5, MediaTile and Alcatel-Lucent will showcase the Virtual Concierge at the Alcatel-Lucent booth #35469 in the South Hall at the Consumer Electronics Show in Las Vegas from January 6-9, 2011.

“This has been one of the most challenging yet rewarding projects that we’ve worked on at Infrared5, and has really made the most of our skills as multi-media programmers. All of the knowledge that we’ve learned over the years, developing open source projects like Red5 Server, and other customer work, have culminated in our efforts with the Virtual Concierge,” said Chris Allen, CEO of Infrared5.  “Working with Alcatel-Lucent and other members within the ng Connect Program has made us realize the market opportunity for us with next generation wireless networks. The Virtual Concierge is a prime example of this.”

“The ng Connect Program and Infrared5 have a shared vision for taking advantage of next generation networks for video streaming, including high definition video streaming that Infrared5 excels in. Working with Infrared5 to develop the Virtual Concierge is just the beginning of our work together on transforming how people connect by taking advantage of 4G/LTE networks, as well as the future of new next generation networks,” said Steve West, Vice President of Emerging Technology and Media at Alcatel-Lucent, a founding member of the ng Connect Program.

About Infrared5

Infrared5 is a consulting firm that specializes in developing cutting-edge experiences for the Flash Platform, Unity 3D and the iPhone. With its all-star team of designers and developers, Infrared5 has excelled at building sites, games, components, virtual worlds and RIAs for companies like NBC Universal, LucasFilm, Adobe, Wrigley’s and Ribbit. Infrared5 is also well known for their leadership role and expertise on the open source projects, Red5 and Papervision3D.

About the ng Connect Program

The ng Connect Program is a multi-industry organization committed to the development and rapid deployment of the next generation of broadband services based on Long Term Evolution (LTE) and other ultra high bandwidth technologies. Founded in 2009, the ng Connect Program is supported by leading network, consumer electronics, application and content providers including 4DK, Alcatel-Lucent, Atlantic Records, BlogRadio, Brass Monkey, BUZZMEDIA, chumby, Connect2Media, CoolSign, Creative Technology Ltd., Desktone, Ecrio, Inc., EON Reality, FISHLABS, GameStreamer, Inc., Gemalto, Genetec, HFMUS, HP, IMS, Infrared5, Intamac Systems Ltd., IVOX, K12, Inc., Kabillion, Kyocera Communications Inc., LearningMate, LiveCast, MediaTile, mental images, Mobideo, Movial, NCR Corporation, Netsweeper, Neusoft Corporation, Nuance Communications, Optical Crime Prevention, Inc., QNX, R360, RebelVox LLC., Samsung, SIGNEXX, Skymeter Corporation, STRATACACHE, [TC]2, TelePresence Tech, Total Immersion, Toyota Motor Sales USA, Inc., TuneWiki, V-Gate, Vidyo, VisionMAX Solutions Inc., Wcities.com, and Words & Numbers. For more information on the ng Connect Program, please visit: www.ngconnect.org. Follow us on Twitter at: http://twitter.com/ngConnect.

Editorial Contacts

Chris Allen, Infrared5                    Tel: +1 617-470-8815               chris@infrared5.com

Pamela Preston, ng Connect         Tel: +1 212-616-6001               ppreston@breakawaycom.com

Alicia Mickelsen, ng Connect         Tel: +1 212-616-6002               amick@breakawaycom.com

, , ,

Flex 4

June 7th, 2010 by Mike Oldham

Intro:

Simply put, Todd is a Flex and AIR guru. He has written three books on the topic – most recently the Flex 4 Cookbook (in stores now!). Todd has been working with Flex since its early days and he’s always ready to take on extremely complex projects. When he’s not coding, he collects and digitizes old vinyl and enjoys riding his bike to work. We finally cornered Todd earlier this month to ask him some questions about the Flex 4 release and his thoughts on the future of the technology.

Read the rest of this entry »

, ,