Skip to content

What are the roles of these servers in NF

wangxiaobai-dd edited this page Dec 24, 2020 · 6 revisions

Architecture

Server Architecture

Master Server

Regarding Master Server, the plugin named NFMasterNet_ServerPlugin holding all Wolrd Server peers and Login Server peers. Besides, the plugin NFMasterNet_HttpServerPlugig provides the HTTP service to expand more features.

Master: Handling Login Server Peers (NFMasterNet_ServerPlugin)

 NFMasterNet_ServerModule::OnLoginRegisteredProcess

The Master called the OnLoginRegisteredProcess function when a Login Server registered to the Master Server

NFMasterNet_ServerModule::OnRefreshLoginInfoProcess

The Master called the OnRefreshLoginInfoProcess function when a Login Server reported the state to the Master Server

Master: Handling World Server Peers (NFMasterNet_ServerPlugin)

NFMasterNet_ServerModule::OnWorldRegisteredProcess

The Master called the OnWorldRegisteredProcess function when a World Server registered to the Master Server

NFMasterNet_ServerModule::OnRefreshWorldInfoProcess

The Master called the OnRefreshWorldInfoProcess function when a World Server reported the state to the Master Server

Master: Providing Http Services (NFMasterNet_HttpServerPlugin)


Login Server

The plugin named NFLoginNet_ServerPlugin holding all client peers when the front-end first time connect to the back-end, once the front-end got the proxy information then disconnect from the Login Server.

Login: Handling Client Peers (NFLoginNet_ServerPlugin)

NFLoginLogicModule::OnClientConnected

The Login Servers call the OnClientConnected operation once one client has connected to the Login Server.

Login: Handling Client Requests (NFLoginLogicPlugin)

NFLoginLogicModule::OnLoginProcess

Login: Providing Http Services (NFLoginNet_HttpServerPlugin)


World Server

The World Server holding all Game Server peers, DB Server peers and Proxy Server peers. Additionally, the World Server responses for reporting the Proxy-State and Game State to the Master Server. Besides, the World Server responses some business that cross Game Server (NFWorldLogicPlugin).

World: Handling Game Server Peers (NFWorldNet_ServerPlugin)


    void OnGameServerRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnGameServerUnRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnRefreshGameServerInfoProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

World: Handling DB Server Peers (NFWorldNet_ServerPlugin)

	void OnDBServerRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnDBServerUnRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnRefreshDBServerInfoProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

World: Handling Proxy Server Peers (NFWorldNet_ServerPlugin)

    void OnProxyServerRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnProxyServerUnRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnRefreshProxyServerInfoProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

World: Reporting World States to the Master (NFWorldNet_ClientPlugin)

NFWorldToMasterModule::ServerReport

The World Servers call the function NFWorldToMasterModule::ServerReport to report the information about the workload to the Master Server per 10 Seconds.

World: Synchronize Status to the Game, DB and Proxy (NFWorldNet_ServerPlugin)

	void SynGameToProxy();
        void SynGameToProxy(const NFSOCK nFD);

	void SynWorldToProxy();
	void SynWorldToProxy(const NFSOCK nFD);

	void SynWorldToGame();
	void SynWorldToGame(const NFSOCK nFD);

	void SynWorldToDB();
	void SynWorldToDB(const NFSOCK nFD);

	void SynDBToGame();
	void SynDBToGame(const NFSOCK nFD);

The World Servers call those functions when the Proxy Server, DB Server and Game Server connected to the World Server or disconnected, which to synchronize the information to all servers.


Game Server

Game Server: Handling Proxy Peers (NFGameServerNet_ServerPlugin)

    void OnProxyServerRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnProxyServerUnRegisteredProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnRefreshProxyServerInfoProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

Game Server: Sending messages to Players (NFGameServerNet_ServerPlugin)

    virtual void SendMsgPBToGate(const uint16_t nMsgID, google::protobuf::Message& xMsg, const NFGUID& self);
	virtual void SendGroupMsgPBToGate(const uint16_t nMsgID, google::protobuf::Message& xMsg, const int nSceneID, const int nGroupID);
	virtual void SendGroupMsgPBToGate(const uint16_t nMsgID, google::protobuf::Message& xMsg, const int nSceneID, const int nGroupID, const NFGUID exceptID);

	virtual void SendMsgToGate(const uint16_t nMsgID, const std::string& strMsg, const NFGUID& self);
	virtual void SendGroupMsgPBToGate(const uint16_t nMsgID, const std::string& strMsg, const int nSceneID, const int nGroupID);
	virtual void SendGroupMsgPBToGate(const uint16_t nMsgID, const std::string& strMsg, const int nSceneID, const int nGroupID, const NFGUID exceptID);

Game Server: Handling messages from players (NFGameServerNet_ServerPlugin)

        m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_ENTER_GAME, this, &NFGameServerNet_ServerModule::OnClientEnterGameProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_LEAVE_GAME, this, &NFGameServerNet_ServerModule::OnClientLeaveGameProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_ROLE_LIST, this, &NFGameServerNet_ServerModule::OnReqRoleListProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_CREATE_ROLE, this, &NFGameServerNet_ServerModule::OnCreateRoleGameProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_DELETE_ROLE, this, &NFGameServerNet_ServerModule::OnDeleteRoleGameProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_SWAP_SCENE, this, &NFGameServerNet_ServerModule::OnClientSwapSceneProcess);
	m_pNetModule->AddReceiveCallBack(NFMsg::EGMI_REQ_ENTER_GAME_FINISH, this, &NFGameServerNet_ServerModule::OnClientEnterGameFinishProcess);

Game Server: Reporting the Game States to the World (NFGameServerNet_ClientPlugin)

The Game Servers call the ServerReport function when connected to the World Server, this function describes how the game servers report their current workload to the World Server.

NFGameServerToWorldModule::ServerReport()

Game Server: Broadcasting messages to players (NFGameServerNet_ServerPlugin)

NFAutoBroadcastModule

This module's job is to broadcast players' property and record to other players


NFSceneAutoBroadcastModule

This module's job is to broadcast the group's property and record to the player who in this group

Game Server: Game Logic (NFGameServerPlugin and NFGameLogicPlugin)


Proxy Server

Proxy Server: Handling Client Peers (NFProxyServerNet_ServerPlugin)

    void OnSocketClientEvent(const NFSOCK nSockIndex, const NF_NET_EVENT eEvent, NFINet* pNet);

    void OnClientDisconnect(const NFSOCK nAddress);
    void OnClientConnected(const NFSOCK nAddress);

    void OnConnectKeyProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnReqServerListProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnSelectServerProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnReqRoleListProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnReqCreateRoleProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnReqDelRoleProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
    void OnReqEnterGameServer(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

    //////////////////////////////////////////////////////////////////////////

    void OnOtherMessage(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);

Proxy Server: Reporting Proxy States to the World (NFProxyServerNet_ClientPlugin)

NFProxyServerToWorldModule::ServerReport()

Proxy Server: Conntecting the Game and World (NFProxyServerNet_ClientPlugin)

NFProxyServerToWorldModule::OnServerInfoProcess

When the Proxy connected to one World Server, that World Server will tell all the World Servers and Game Server to this Proxy, then this Proxy will try to connect those servers.


DB Server

DB Server: Handling Client Peers (NFDBNet_ServerPlugin)

	void OnClientDisconnect(const NFSOCK nAddress);
	void OnClientConnected(const NFSOCK nAddress);

	void OnRequireRoleListProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnCreateRoleGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnDeleteRoleGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnLoadRoleDataProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
	void OnSaveRoleDataProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);


DB Server: Reporting DB States to the World Server (NFDBNet_ClientPlugin)

NFDBToWorldModule::ServerReport

DB Server: Connecting the World Server (NFDBNet_ClientPlugin)

NFDBToWorldModule::AfterInit()
NFDBToWorldModule::Register(NFINet* pNet)

In terms of DB Server, if you want to debug and store the player's data, please running REDIS with pasword NoahGameFrame which like below:

requirepass "hello world"

NoSqlServer.xlsx

MidWare

Clone this wiki locally