开发者

Handling Server-side RtmpConnection.Invoke() when connecting with NetConnection as a client using FluorineFx

I am trying to create a basic console app in order to stress test our FluorineFx based flash remoting server.

I can connect fine but the server method I am calling invokes this client-side function:

connection.Invoke("onServerDataPush", new string[] { "someParam", "anotherParam" });

I am struggling to find out how I can expose this method to the connection. The NetConnection.Call() method allow you to pass in a callback but the result of this is always null and the NetConnection call fails with the following error:

Could not find a suitable method with name onServerDataPush

Here is my client-side code:

class Program
{
    private NetConnection _netConnection;

    static void Main(string[] args)
    {
        var program = new Program();
        program.Connect();
        Console.ReadLine();
    }

    public void Connect()
    {
        _netConnection = new NetConnection();
        _netConnection.ObjectEncoding = ObjectEncoding.AMF3;
        _netConnection.OnConnect += netConnection_OnConnect;
        _netConnection.NetStatus += netConnection_NetStatus;
        _netConnection.Connect("rtmp://localhost:1935/MyApplication");
    }

    void netConnection_OnConnect(object sender, EventArgs e)
    {
        var responder = new Responder<object>(x =>
                                                  {
 开发者_JAVA百科                                                     var test = x;
                                                  });

        //The NetConnection object is connected now
        _netConnection.Call("MyServerMethod", responder, "someParameter");
    }
    void netConnection_NetStatus(object sender, NetStatusEventArgs e)
    {
        string level = e.Info["level"] as string;
    }
}


Debugging through RtmpClient line 308 finally allowed me to solve this.

You must set the NetConnection.Client property to the class that contains a method of the same signature as the one being invoked by the server (in my case this as the method is in the Program class).

    public void onServerDataPush(string type, string json)
    {

    }

FluorineFx then calls the method using reflection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜