小范围修改 删除打印
This commit is contained in:
27
MS/MS.cpp
27
MS/MS.cpp
@@ -5,13 +5,14 @@
|
||||
#include "MS.h"
|
||||
#include <cstring>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "event2/listener.h"
|
||||
|
||||
|
||||
ev_pool* MS::pool = nullptr;
|
||||
class management* MS::mage = nullptr;
|
||||
MS::MS() {
|
||||
|
||||
pool = new ev_pool(4);
|
||||
pool->add_event_base(listener);
|
||||
pool->add_event_bases(4);
|
||||
@@ -52,19 +53,34 @@ void MS::link(struct evconnlistener *e, int fd, struct sockaddr *addr, int sockl
|
||||
perror("en: Prohibit manual static invocation MS::link()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("listen_cb\n");
|
||||
pool->add_buffer_event(fd, read_cb, write_cb, event_cb, BEV_OPT_CLOSE_ON_FREE);
|
||||
pool->add_buffer_event(fd, read_cb, write_cb, event_cb,
|
||||
BEV_OPT_CLOSE_ON_FREE, (sockaddr_in*)addr);
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void MS::read_cb(struct bufferevent *bev, void *ctx) {
|
||||
printf("[read]: %p, %p\n", ctx, bev);
|
||||
mage->read_packet(bev);
|
||||
BBCA* bbca = (BBCA*) ctx;
|
||||
auto addr = bbca->addr;
|
||||
auto base = bbca->base;
|
||||
|
||||
printf("[read]: ip:%s, bev:%p, fd:%d, base:%p\n",
|
||||
inet_ntoa(addr->sin_addr), bev, bufferevent_getfd(bev), base);
|
||||
if (!mage) {
|
||||
mage = new class management();
|
||||
}
|
||||
mage->read_packet(bev, (sockaddr_in*)ctx);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void MS::write_cb(struct bufferevent *bev, void *ctx) {
|
||||
printf("[write]: %p\n", ctx);
|
||||
BBCA* bbca = (BBCA*) ctx;
|
||||
auto addr = bbca->addr;
|
||||
auto base = bbca->base;
|
||||
|
||||
printf("[write]: %p\n", base);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -73,7 +89,6 @@ void MS::event_cb(struct bufferevent *bev, short what, void *ctx) {
|
||||
if (what == BEV_EVENT_EOF || BEV_EVENT_ERROR || BEV_EVENT_TIMEOUT) {
|
||||
printf("客户端退出\n");
|
||||
handler::remove_user(bev);
|
||||
bufferevent_free(bev);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
Reference in New Issue
Block a user