NoahFrame

服务器端开发解决方案
授权协议 Apache
开发语言 C/C++
所属分类 程序开发、 服务框架/平台
软件类型 开源软件
地区 国产
投 递 者 钱震博
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

NoahFrame(以下简称NFrame/NF)是一个容易开发、高性能的跨平台的服务器端开发解决方案。

主要特点:

  • 跨平台

  • 分布式架构

  • 插件化、模块化

  • 良好的对象与可配的数据管理

  • 面向接口编程

  • 数据的事件驱动

  • 高性能,高并发(网络,actor,逻辑开发)

  • 支持多种脚本语言(lua, python,js, c#)

  • 简单配置,所有数据全面支持excel配置

  • excel数据转换配套工具(xls2xml等等)

  • 匹配的U3D客户端源码

  • 轻松上手,包学包会

示例代码:

Tutorial1 :hello world

Tutorial2 :事件驱动与数据驱动

Tutorial6:lua脚本运行示例

#include "HelloWorld3Module.h"
#include "NFComm/NFCore/NFTimer.h"

bool HelloWorld3Module::Init()
{
    //初始化
    std::cout << "Hello, world3, Init" << std::endl;

    return true;
}

int HelloWorld3Module::OnEvent(const NFIDENTID& self, const int event, const NFIDataList& arg)
{
    //事件回调函数
    std::cout << "OnEvent EventID: " << event << " self: " << self.nData64 << " argList: " << arg.Int(0) << " " << " " << arg.String(1) << std::endl;

    m_pKernelModule->SetPropertyInt(self, "Hello", arg.Int(0));
    m_pKernelModule->SetPropertyString(self, "Hello", arg.String(1));

    return 0;
}

int HelloWorld3Module::OnHeartBeat(const NFIDENTID& self, const std::string& strHeartBeat, const float fTime, const int nCount, const NFIDataList& arg)
{

    unsigned long unNowTime = NF_GetTickCount();

    std::cout << "strHeartBeat: " << fTime << " Count: " << nCount << "  TimeDis: " << unNowTime - mLastTime << std::endl;

    mLastTime = unNowTime;

    return 0;
}

int HelloWorld3Module::OnClassCallBackEvent(const NFIDENTID& self, const std::string& strClassName, const CLASS_OBJECT_EVENT event, const NFIDataList& arg)
{
    //虚拟类事件,只要有此虚拟类创建或者销毁即会回调
    std::cout << "OnClassCallBackEvent ClassName: " << strClassName << " ID: " << self.nData64 << " Event: " << event << std::endl;

    if (event == COE_CREATE_HASDATA)
    {
#ifdef NF_USE_ACTOR
        if(pPluginManager->GetActorID() == NFIActorManager::EACTOR_MAIN)
#endif
        {
            m_pEventProcessModule->AddEventCallBack(self, 11111111, this, &HelloWorld3Module::OnEvent);

            m_pKernelModule->AddHeartBeat(self, "OnHeartBeat", this, &HelloWorld3Module::OnHeartBeat, NFCDataList(), 5.0f, 9999 );

            mLastTime = NF_GetTickCount();
        }
    }

    return 0;
}

int HelloWorld3Module::OnPropertyCallBackEvent( const NFIDENTID& self, const std::string& strProperty, const NFIDataList& oldVarList, const NFIDataList& newVarList, const NFIDataList& argVarList )
{
    //属性回调事件,只要属性值内容有变化,就会被回调
    std::cout << "OnPropertyCallBackEvent Property: " << strProperty << " OldValue: " << oldVarList.Int(0) << " NewValue: " << newVarList.Int(0) << std::endl;

    return 0;
}

int HelloWorld3Module::OnPropertyStrCallBackEvent( const NFIDENTID& self, const std::string& strProperty, const NFIDataList& oldVarList, const NFIDataList& newVarList, const NFIDataList& argVarList )
{
    //属性回调事件,只要属性值内容有变化,就会被回调
    std::cout << "OnPropertyCallBackEvent Property: " << strProperty << " OldValue: " << oldVarList.String(0) << " NewValue: " << newVarList.String(0) << std::endl;

    return 0;
}

bool HelloWorld3Module::AfterInit()
{
    //初始化完毕
    std::cout << "Hello, world3, AfterInit" << std::endl;

    m_pKernelModule = dynamic_cast<NFIKernelModule*>(pPluginManager->FindModule("NFCKernelModule"));
    m_pEventProcessModule = dynamic_cast<NFIEventProcessModule*>(pPluginManager->FindModule("NFCEventProcessModule"));
    m_pElementInfoModule = dynamic_cast<NFIElementInfoModule*>(pPluginManager->FindModule("NFCElementInfoModule"));

    //创建容器,所有的对象均需在容器中
    m_pKernelModule->CreateContainer(1, "");

    m_pEventProcessModule->AddClassCallBack("Player", this, &HelloWorld3Module::OnClassCallBackEvent);

    //创建对象,挂类回调和属性回调,然后事件处理对象
    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(NFIDENTID(0, 10), 1, 0, "Player", "", NFCDataList());
    if (!pObject)
    {
        return false;
    }

    pObject->GetPropertyManager()->AddProperty(pObject->Self(), "Hello", TDATA_STRING, true, true, true, true, 0, "");
    pObject->GetPropertyManager()->AddProperty(pObject->Self(), "World", TDATA_INT, true, true, true, true, 0, "");

    pObject->AddPropertyCallBack("Hello", this, &HelloWorld3Module::OnPropertyStrCallBackEvent);
    pObject->AddPropertyCallBack("World", this, &HelloWorld3Module::OnPropertyCallBackEvent);

    pObject->SetPropertyString("Hello", "hello,World");
    pObject->SetPropertyInt("World", 1111);


    m_pEventProcessModule->DoEvent(pObject->Self(), 11111111, NFCDataList() << int(100) << "200");

    return true;
}

bool HelloWorld3Module::Execute( const float fLasFrametime, const float fStartedTime )
{
    //每帧执行
    //std::cout << "Hello, world3, Execute" << std::endl;

    return true;
}

bool HelloWorld3Module::BeforeShut()
{
    //反初始化之前
    std::cout << "Hello, world3, BeforeShut" << std::endl;

    m_pKernelModule->DestroyAll();

    return true;
}

bool HelloWorld3Module::Shut()
{
    //反初始化
    std::cout << "Hello, world3, Shut" << std::endl;

    return true;
}

PS:我们的目标是用优良的设计打败实现狗!

码云代码: https://gitee.com/kytoo/NoahGameFrame

Github代码: https://github.com/ketoo/NoahGameFrame

 
  • NF最早为客户端设计,后来随着时代的变化,而为自己又转为服务器开发,故在吸收了众多引擎的优点后(包含Ogre的插件模式&模块化管理机制,Bigworld的数据管理&配置机制,类似MYGUI的接口层次设计),经过多年演化和实践,变成了一套游戏开发J解决方案。方案中包含开源的服务器架构,网络库(站在libevent的肩膀上),和unity3d的demo源码。现在NF已经在多个公司的多个项目中使用,其中

  •  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29609.76 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474

  • 开源服务器框架NoahFrame分享:第二章 插件与模块 NF(https://github.com/ketoo/NoahGameFrame)全称为 NoahFrame/NoahGameFrame。 NF最早为客户端设计,后来随着时代的变化,而为自己又转为服务器开发,故在吸收了众多引擎的优点后(包含Ogre的插件模式&模块化管理机制,Bigworld的数据管理&配置机制,类似MYGUI的接口层次设

 相关资料
  • 本文向大家介绍Java服务器端跨域问题解决方案,包括了Java服务器端跨域问题解决方案的使用技巧和注意事项,需要的朋友参考一下 这篇文章主要介绍了java服务器端跨域问题解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 现在很多开发的 API 都支持 ajax 直接请求,这样就会导致跨域的问题,解决跨域的问题一方面可以从前端,另一方面就是服

  • SRS不支持服务器端脚本,所谓服务器端脚本,指的是服务器可以加载外部脚本文件,解释并执行。 支持服务器脚本的服务器有FMS,语言是actionscript1.0;nginx支持的是lua。 SRS不支持服务器脚本的原因有: 不Simple:违反了SRS(Simple RTMP Server)的第一个S,支持扩展脚本,出错的几率也扩展了。 实际用处很小:我在国内知名的CDN公司工作时,所在部门就是用

  • 本文向大家介绍tomcat服务器宕机解决方案,包括了tomcat服务器宕机解决方案的使用技巧和注意事项,需要的朋友参考一下 报错信息: 每次出现这个报错都会导致tomcat应用服务器停机,加了下面的java代码后就再也没有停过了。 解决办法: 编写Java代码 @WebListener,这个注解相当于在web.xml配置如下内容 解决方案可以参考如下网址 当然还有就是我再参考这个解决方案的时候,发

  • 本文向大家介绍JSP服务器端和前端出现乱码问题解决方案,包括了JSP服务器端和前端出现乱码问题解决方案的使用技巧和注意事项,需要的朋友参考一下 这篇文章主要介绍了JSP服务器端和前端出现乱码问题解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 在前端和服务器端交互的过程中主要是通过HTTP协议进行交互的,而在Servlet接口中有提供一个H

  • 问题内容: 我正在尝试使用python开发客户端/服务器解决方案,服务器必须使用Avahi广播服务可用性。我正在使用以下代码来发布服务: 对于客户端,我正在尝试通过以下方式搜索服务: 但是,客户端没有检测到服务何时启动。有什么想法我做错了吗? 问题答案: 我发现该代码按预期工作。我有防火墙规则阻止avahi相关的发布。

  • Example: 102basic 你可以在服务端实现Service。 Service的类型并不重要。你可以使用自定义类型来保持状态,或者直接使用 struct{}、 int。 你需要启动一个TCP或UDP服务器来暴露Service。 你也可以添加一些plugin来为服务器增加新特性。 Service 作为服务提供者,首先你需要定义服务。 当前rpcx仅支持 可导出的 methods (方法) 作