49 lines
968 B
C
49 lines
968 B
C
#ifndef NETWORK
|
|
#define NETWORK
|
|
|
|
#define MAX_POOL 24
|
|
#define MAX_MESSAGE_BUF 10240
|
|
#include <pthread.h>
|
|
#include<tools/log/log.h>
|
|
#include <stdatomic.h>
|
|
//单个线程模型
|
|
typedef struct pthread_module
|
|
{
|
|
pthread_t pthread_id;
|
|
int fifo_fd[2];
|
|
atomic_int status;
|
|
}pth_m;
|
|
|
|
typedef struct args
|
|
{
|
|
log_manager *log;
|
|
pth_m *pth;
|
|
}args;
|
|
|
|
typedef struct network_manager
|
|
{
|
|
void *(*run_network)(void*);
|
|
int (*start_pool)(struct network_manager*);
|
|
int (*shutdown_pool)(struct network_manager*);
|
|
int (*iss_work)(struct network_manager*,char *);
|
|
pth_m pool[MAX_POOL];
|
|
int fifo_fd[2];
|
|
log_manager *logmanager;
|
|
int last_alc;
|
|
int port;
|
|
}netm;
|
|
|
|
typedef struct rebot_message
|
|
{
|
|
char gid[32];
|
|
char uid[32];
|
|
char nickname[64];
|
|
char raw_message[MAX_MESSAGE_BUF];
|
|
char message_type;
|
|
sem_t status;
|
|
int state;
|
|
}rbt_msg;
|
|
|
|
int init_networkmanager(netm *self,int *fifo,log_manager *logmanager,int port);
|
|
|
|
#endif |