Developing Adobe Flex chat client

Together the Adobe Flex framework and BlazeDS framework provide infrastructure to create messaging/chat type of application. You can use the infrastructure to either create one to one or broadcast type of application.

I wanted to try this feature so i built a simple broadcast application, in which there will be one chat destination and multiple clients and connect to it and publish and subscribe messages from it. You can download that application from here

First download the BlazeDS application and use it for creating a new J2EE application.

Then open the messaging-config.xml, which has messaging related configuration required for BlazeDS and add a destination element in it like this

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"

<adapter-definition id="actionscript"
default="true" />
<!-- <adapter-definition id="jms"
class=""/> -->

<channel ref="my-polling-amf"/>

<destination id="chat"/>

The chat destination will be used by flex application for both publishing and subscribing messages

Next create a ChatClient.mxml file like this

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=""
xmlns:mx="library://" minWidth="955"
minHeight="600" creationComplete="consumer.subscribe()">

<mx:Consumer id="consumer" destination="chat" message="messageHandler(event.message)"/>
<mx:Producer id="producer" destination="chat"/>

import mx.messaging.messages.AsyncMessage;
import mx.messaging.messages.IMessage;

private function send():void{
var message:IMessage = new AsyncMessage();
message.body.chatMessage = msg.text;
msg.text = "";
private function messageHandler(message:IMessage):void{
log.text += message.body.chatMessage + "\n";
<mx:Panel title="Chat" width="100%" height="100%">
<mx:TextArea id="log" width="100%" height="100%"/>
<mx:TextInput id="msg" width="100%" enter="send()"/>
<mx:Button label="Send B" click="send()"/>

I am using declarative message handling, the mx:Consumer element declares that your interested in chat destination its messageHandler() method will get whenever there is a new message chat destination.

The mx:Producer element is used for publishing messages to the destination, i am calling its send() method to publish the text to the desination

4 comments: said...

Flex Application development- Flex is one of the most powerful RIA development platform that is based on the mighty Flash architecture. Flex development provides the developer to build web based applications that run on the client browser and function as typical desktop based software. We provide flex application development services at affordable price in India.

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store