开发者

How to create Handler

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开发者_JAVA百科 to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>


_socketManager->onDataArrival += gcnew DataArrival(this,
    &Test::Form1::_socketManager_onDataArrival_);

DataArrival is delegate:

public delegate DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);

Possibly it is already defined somewhere, with other name - look this delegate definition in Emily namespace.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜