如何创建处理程序
添加下一个更改:
Emily::oSeMac^ Terminal;
Emily::AsyncSocketController^ _socketManager;
delegate void DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);
void _socketManager_onDataArrival(String^ SocketID, array<unsigned char, 1>^ SocketData, System::Net::IPEndPoint^ RemoteIP)
{
System::Object^ retData = Terminal->WhoCame (SocketID, SocketData, RemoteIP, _socketManager, 0);
}
Form1(void)
{
InitializeComponent();
_socketManager = gcnew Emily::AsyncSocketController(2000);
_socketManager->onDataArrival += gcnew DataArrival(this, &AC_WebPassManager::Form1::_socketManager_onDataArrival);
_socketManager->Start();
Terminal = gcnew Emily::oSeMac();
}
错误错误 C2664: 'Emily::AsyncSocketController::onDataArrival::add' : 无法将参数 1 从 'AC_WebPassManager::Form1::DataArrival ^' 转换为 'Emily::AsyncSocketController::onDataArrivalEventHandler ^' 1>没有可用的用户定义转换运算符,或者 1>指向的类型是不相关的;转换需要reinterpret_cast、C 风格转换或函数风格转换 1>
Add next changes:
Emily::oSeMac^ Terminal;
Emily::AsyncSocketController^ _socketManager;
delegate void DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);
void _socketManager_onDataArrival(String^ SocketID, array<unsigned char, 1>^ SocketData, System::Net::IPEndPoint^ RemoteIP)
{
System::Object^ retData = Terminal->WhoCame (SocketID, SocketData, RemoteIP, _socketManager, 0);
}
Form1(void)
{
InitializeComponent();
_socketManager = gcnew Emily::AsyncSocketController(2000);
_socketManager->onDataArrival += gcnew DataArrival(this, &AC_WebPassManager::Form1::_socketManager_onDataArrival);
_socketManager->Start();
Terminal = gcnew Emily::oSeMac();
}
Error error C2664: 'Emily::AsyncSocketController::onDataArrival::add' : cannot convert parameter 1 from 'AC_WebPassManager::Form1::DataArrival ^' to 'Emily::AsyncSocketController::onDataArrivalEventHandler ^'
1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DataArrival 是委托:
可能它已经在某处以其他名称定义 - 在 Emily 命名空间中查看此委托定义。
DataArrival is delegate:
Possibly it is already defined somewhere, with other name - look this delegate definition in Emily namespace.