DatagramServer is small library for Flex+Parsley that allows you to set up and manage a UDP listener in your Air 2.5+ application.
http://zoltanb.co.uk/flex-datagram-server/
- integration-0.15.swc
- integrationParsley-0.15.swc
- observer-1.13.swc
- parsley-flex4-2.4.M2.swc
- spicelib-flex-2.4.M2.swc
- In your Parsley contextbuilder register DatagramServerContext:
<parsley:FlexConfig type="{ DatagramServerContext }"/>
- If you want to edit the datagram host and port from the UI, fastinject DatagramModel, then create a two way binding to .host and .port:
<s:TextInput text="@{data.host}" width="120" /> <s:TextInput text="@{data.port}" width="40" />
- Start/Stop the Datagram server from any parsley-managed class, eg.::
dispatcher(new Event(DatagramServerEvent.START)); dispatcher(new Event(DatagramServerEvent.STOP));
- To listen to incoming UDP packages, create a parsley messagehandler:
[MessageHandler] public function dataReceived(e:DataReceivedEvent):void { logs.add(e.string); /** * you can also use: * e.ip : returns the IP of the sender * e.data : returns the packet as a bytearray * e.xml : returns the packet as xml */ }