Skip to main content
Known Participant
October 2, 2009
Question

Part 2: Best practices question: multiple or single NetConnection object per application

  • October 2, 2009
  • 1 reply
  • 701 views

As I've looked back on the other post with this title I was wondering if we get data "to" the FMS the same way we got it "from" FMS.

We got it "from" FMS through a NetConnectionManager class that served as a proxy between the components in the app (chat, video, slide dec) and FMS.  When FMS called the client app, the NCMgr class dispatched events containg data, and the components listened for and handled them.  I'm wondering what the reverse is.

If my app's chat component, for instance,  has data to push "to" FMS, it's got to do that through the NCMgr because the NCMgr has the NetConnection.  The NCMgr is not scoped to the chat component.  It's scoped to the app's main mxml file.  Do we do the reverse and have the chat component dispatch events that get handled by the NCMgr?

    This topic has been closed for replies.

    1 reply

    October 2, 2009

    There are a few ways you can approach this:

    1. Let the NCMgr class register as a listener of the chat component, and have the chat component dispatch messages to be sent (that's my personal preference)

    2. Make the chat send method on the NCMgr public, pass a reference of the NcMgr to the chat component, and let the component invoke the send method by itself

    3. Make the netconnection var in the NCMgr public, and pass a reference of the NC to the chat component. Then the chat can make calls on the NC directly.

    Known Participant
    October 2, 2009

    Thanks.  I like #1 as well.  Started down that road and have the chat working now.  Same concept will apply to other components in the app.

    Nice to know what others are doing out there.  Obviously want to eliminate component dependencies anywhere possible.  Never considered custom events would play such a large role in FMS dev.

    I know there are frameworks that address these issues.  Reading about some of them now.  Data access is a big focus of them and this app doesn't have much yet.  But it will someday.  This will be a nice example to implement in one of them.

    October 2, 2009

    The developers at Influxis have some sort of FMS framework... I seem to remember reading about its recent release somewhere. Check their blog.

    Truth be told, I'm not a framework fan (save the Flex framework). Maybe it's just the nature of the applications I develop, but I always seem to get the job done a lot faster [and using a whole lot less code] when I don't build on top of someone else's code.