⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 network.h

📁 网络游戏通用架构, 这是基于boost和libevent写的一个程序
💻 H
字号:
#ifndef NETWORK_H
#define NETWORK_H

#include <stddef.h>
#include <assert.h>
#include <list>
#include <algorithm>
#include <iostream>

#include "common.h"
#include "module.h"
#include "socket_api.h"
#include "connection.h"

using namespace std;

class World;

class EXPORT Network : public Module
{
    friend class World;
public:
    Network();
    ~Network();
public:
    void breathe(void);
    int listen( int __port, int __backlog );    Connection* connect( const char* __server_ip, int __port );
    void disconnect( Connection* __conn );
    list<Connection*>& getConnections()
    {
        recursive_mutex::scoped_lock lock( _mutex );
        return _connections;
    }
    void accepted( Connection* __conn );
protected:
    int init(void);
    void shutdown(void);
protected:
    list<Connection*> _connections;
protected:
    class ConnectionFindOp    {    public:    ConnectionFindOp( const Connection* __conn ) : _conn(__conn) {}    bool operator() ( const Connection* __conn )    {        assert( __conn );        return ( __conn==_conn );    }    const Connection* _conn;    };
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -