Flex Datagram Server
DatagramServer is small library for Flex+Parsley that allows you to set up and manage a UDP listener in your Air 2.5+ application.
UDP Packets in Flex Air apps
Datagram packets are ideal for gathering data from external devices without having to establish two-way persistent socket connections. Perfect for gathering logs, benchmark data, statistics, …etc.
Note: You can send and receive UDP packets in Air 2.5+, but only on desktop Air apps. MobileDevice, extendedMobileDevice, tv, extendedTV profiles are unsupported.
You can download the DatagramServer swc from github:
Setup
- In your Parsley contextbuilder register 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:
- Start/Stop the Datagram server from any parsley-managed class, eg.::
- 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 */ }
[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 */ }
How to test your Datagram Listener
You can use Netcat to send udp packages. On a mac:
Example
One Response to Flex Datagram Server
Leave a Reply Cancel reply
Tags
3D Printing air apparat as3 colours cpd datagram FDT flash flash builder flex FlexCPD FlexMetrics FlexPMD flex skinning FlexUnit git grails groovy hudson jenkins joomla Launchpad linux mac maven Maya netfabb os x lion parsley performance pmd replicatorg reprap scala scien scientific linux sonar sts subclipse svn udp ultimakerBlogroll




… [Trackback]…
[...] Read More: zoltanb.co.uk/flex-datagram-server/ [...]…