Commit 5bb84f42 authored by jan.koester's avatar jan.koester
Browse files

use new api

parent 82e319a2
Loading
Loading
Loading
Loading
+19 −17
Changes for src/event/kqueue.cpp: 19 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ namespace netplus {
        ~poll() {
            int maxcon=_ServerSocket->getMaxconnections();
            for (int i = 0; i < maxcon; ++i){
                _evtapi->deleteConnetion((con*)_Events[i].udata);
                _evtapi->DestroyConnection((con*)_Events[i].udata);
            }
            delete _Events;
        };
@@ -160,7 +160,7 @@ namespace netplus {
            NetException exception;
            con *ccon;

            _evtapi->CreateConnetion(&ccon);
            _evtapi->CreateConnection(&ccon);

            if(_ServerSocket->_Type==sockettype::TCP){
                ccon->csock=new tcp();
@@ -192,7 +192,7 @@ namespace netplus {
                exception[NetException::Error] << "ConnectEventHandler: can't add socket to kqueue: " << errstr;
                throw exception;
            }
            _evtapi->ConnectEvent(ccon,tid,args);
            _evtapi->ConnectEvent(*ccon,tid,args);

        };

@@ -202,17 +202,17 @@ namespace netplus {
            if(!rcon)
                assert(0);
            try{
                std::shared_ptr<char> buf(new char[BLOCKSIZE]);
                size_t rcvsize = rcon->csock->recvData(buf.get(), BLOCKSIZE);
                buffer buf(BLOCKSIZE);
                size_t rcvsize = rcon->csock->recvData(buf,0);

                rcon->lasteventime = time(nullptr);

                if(rcvsize>0){
                    rcon->RecvData.append(buf.get(),rcvsize);
                    rcon->RecvData.append(buf.data.buf,rcvsize);
                    rcon->state=EVIN;
                }

                _evtapi->RequestEvent(rcon,tid,args);
                _evtapi->RequestEvent(*rcon,tid,args);

                if(!rcon->SendData.empty()){
                    rcon->state=EVOUT;
@@ -236,7 +236,7 @@ namespace netplus {
            con *wcon = (con*)_Events[pos].udata;
            try{

                _evtapi->ResponseEvent(wcon,tid,args);
                _evtapi->ResponseEvent(*wcon,tid,args);

                if(wcon->SendData.empty()){
                    wcon->state=EVIN;
@@ -251,7 +251,9 @@ namespace netplus {

                wcon->state=EVOUT;

                sended = wcon->csock->sendData(wcon->SendData.data(),ssize);
                buffer buf(wcon->SendData.data(),ssize);

                sended = wcon->csock->sendData(buf,0);
                wcon->SendData.resize(sended);

                wcon->lasteventime = time(nullptr);
@@ -290,9 +292,9 @@ namespace netplus {

                delete  ccon->csock;

                _evtapi->DisconnectEvent(ccon,tid,args);
                _evtapi->DisconnectEvent(*ccon,tid,args);

                _evtapi->deleteConnetion(ccon);
                _evtapi->DestroyConnection(ccon);

            }catch(NetException &e){
                throw e;
@@ -377,27 +379,27 @@ namespace netplus {
        }
    };

    void eventapi::RequestEvent(con *curcon,const int tid,ULONG_PTR args){
    void eventapi::RequestEvent(con &curcon,const int tid,ULONG_PTR args){
        //dummy
    };

    void eventapi::ResponseEvent(con *curcon,const int tid,ULONG_PTR args){
    void eventapi::ResponseEvent(con &curcon,const int tid,ULONG_PTR args){
        //dummy
    };

    void eventapi::ConnectEvent(con *curcon,const int tid,ULONG_PTR args){
    void eventapi::ConnectEvent(con &curcon,const int tid,ULONG_PTR args){
        //dummy
    };

    void eventapi::DisconnectEvent(con *curcon,const int tid,ULONG_PTR args){
    void eventapi::DisconnectEvent(con &curcon,const int tid,ULONG_PTR args){
        //dummy
    };

    void eventapi::CreateConnetion(con **curcon){
    void eventapi::CreateConnection(con **curcon){
        *curcon=new con(this);
    };

    void eventapi::deleteConnetion(con *curcon){
    void eventapi::DestroyConnection(con *curcon){
        delete curcon;
    };