我正在尝试创建一个基本的控制台应用程序,以便对我们基于 FluorineFx 的闪存远程处理服务器进行压力测试。
我可以正常连接,但我正在调用的服务器方法调用了这个客户端函数:
connection.Invoke("onServerDataPush", new string[] { "someParam", "anotherParam" });
我正在努力找出如何将此方法公开给连接。NetConnection.Call() 方法允许您传入回调,但其结果始终为 null,并且 NetConnection 调用失败并出现以下错误:
Could not find a suitable method with name onServerDataPush
这是我的客户端代码:
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 =>
{
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;
}
}