CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2009
    Posts
    4

    Issue with scope

    I'm very inexperienced, so please bear with me..

    I'm using open source code from FlourineFX. I'm needing to get a value from an object, but the scope of the object is limited to being instantiated as part of a parameter (new AmfResult).

    _netConnection.Call(command, new AmfResult() , new object[] { file, 103207, true, null, 1.859671316E9 });

    Here is AmfResult code:

    public class AmfResult : IPendingServiceCallback
    {

    public void ResultReceived(PollAmf.IPendingServiceCall call)
    {
    result = call.Result;

    }
    }

    I know nothing of containers, which IPendingServiceCallback is. I can't change the return type, or I'll get a compile error. My question is how can I get the value of result out of this instance?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Issue with scope

    Please post the complete code from when you make the NetConnection.

  3. #3
    Join Date
    Nov 2009
    Posts
    4

    Re: Issue with scope

    There's not much to it. Most of it I got from the samples

    public class AmfConnect
    {
    public AmfConnect(ArrayList args)
    {

    ServerConnect(args);

    }
    private void ServerConnect(ArrayList args)
    {
    //get args from array list
    string server = args[0].ToString();
    string command = args[1].ToString();
    string file = args[2].ToString();

    // Create NetConnection client
    NetConnection connection;
    connection = new NetConnection();
    connection.ObjectEncoding = ObjectEncoding.AMF3;

    //connection.NetStatus += new NetStatusHandler(_netConnection_NetStatus);

    //This is an example of a good connection
    //connection.Connect("http://c.brightcove.com/services/messagebroker/amf");
    connection.Connect(server);

    //This is an example of a good call
    //connection.Call("com.brightcove.player.runtime.PlayerMediaFacade.findMediaById", new AmfResult(), new object[] { 5.3500013001E10, 103207, true, null, 1.859671316E9 });


    connection.Call(command, new AmfResult() , new object[] { file, 103207, true, null, 1.859671316E9 });


    }
    }

    public class AmfResult : IPendingServiceCallback
    {
    object result;


    public void ResultReceived(IPendingServiceCall call)
    {
    result = call.Result;

    }
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    4

    Re: Issue with scope

    I am using C# 2008 Express edition.

  5. #5
    Join Date
    Sep 2006
    Posts
    31

    Re: Issue with scope

    just make a getter for result in afmresult

  6. #6
    Join Date
    Nov 2009
    Posts
    4

    Re: Issue with scope

    Basically I've got a form class "GetAmf" that has a button, "Go". The code for the go button is:

    ArrayList args = new ArrayList { "value1," "value2", "value3"};

    AmfConnect VidData = new AmfConnect(args);

    After doing some reading and adding some code, similar to what was suggested, I was stepping through and it appears that the "new AmfResult()" in "connection.Call" is not being processed until after VidData is instantiated. I'm assuming this is why I can't access any value generated my AmfResult class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured