Skip to content

mere/DatagramServer

Repository files navigation

Flex DatagramServer

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/

Dependencies

  • integration-0.15.swc
  • integrationParsley-0.15.swc
  • observer-1.13.swc
  • parsley-flex4-2.4.M2.swc
  • spicelib-flex-2.4.M2.swc

Setup

  1. In your Parsley contextbuilder register DatagramServerContext:


    <parsley:FlexConfig type="{ DatagramServerContext }"/>
  2. 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" />
  3. Start/Stop the Datagram server from any parsley-managed class, eg.::
    dispatcher(new Event(DatagramServerEvent.START));
    dispatcher(new Event(DatagramServerEvent.STOP));
  4. 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
    */
    }
  5. Demo

About

Flex + Parsley Datagram Server for Air 2.5+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published