FIX 4.0 Demo 1.0
Loading...
Searching...
No Matches
fix40::SessionManager Class Reference

FIX 会话管理器 More...

#include <session_manager.hpp>

Collaboration diagram for fix40::SessionManager:
Collaboration graph

Public Member Functions

 SessionManager ()=default
 构造会话管理器
 
 ~SessionManager ()=default
 析构函数
 
 SessionManager (const SessionManager &)=delete
 
SessionManageroperator= (const SessionManager &)=delete
 
void registerSession (std::shared_ptr< Session > session)
 注册会话
 
bool unregisterSession (const SessionID &sessionID)
 注销会话
 
std::shared_ptr< SessionfindSession (const SessionID &sessionID) const
 查找会话
 
bool sendMessage (const SessionID &sessionID, FixMessage &msg)
 向指定会话发送消息
 
size_t getSessionCount () const
 获取活跃会话数量
 
bool hasSession (const SessionID &sessionID) const
 检查会话是否存在
 
void forEachSession (std::function< void(const SessionID &, std::shared_ptr< Session >)> callback) const
 遍历所有会话
 

Detailed Description

FIX 会话管理器

线程安全地管理所有活跃的 FIX 会话,提供:

  • 会话注册/注销
  • SessionID 查找会话
  • 向指定会话发送消息
使用场景
MatchingEngine 产生 ExecutionReport 后,通过 SessionManager 找到对应的 Session 并发送消息。
线程安全
所有公共方法都是线程安全的。
使用示例
// 注册会话
manager.registerSession(session);
// 发送消息
FixMessage report;
// ... 构建 ExecutionReport ...
manager.sendMessage(sessionID, report);
// 注销会话
manager.unregisterSession(sessionID);
FIX 消息的面向对象封装
Definition fix_codec.hpp:46
FIX 会话管理器
Definition session_manager.hpp:62
bool unregisterSession(const SessionID &sessionID)
注销会话
Definition session_manager.cpp:31
void registerSession(std::shared_ptr< Session > session)
注册会话
Definition session_manager.cpp:11
bool sendMessage(const SessionID &sessionID, FixMessage &msg)
向指定会话发送消息
Definition session_manager.cpp:51

Constructor & Destructor Documentation

◆ SessionManager() [1/2]

fix40::SessionManager::SessionManager ( )
default

构造会话管理器

◆ ~SessionManager()

fix40::SessionManager::~SessionManager ( )
default

析构函数

◆ SessionManager() [2/2]

fix40::SessionManager::SessionManager ( const SessionManager )
delete

Member Function Documentation

◆ findSession()

std::shared_ptr< Session > fix40::SessionManager::findSession ( const SessionID sessionID) const

查找会话

Parameters
sessionID会话标识符
Returns
std::shared_ptr<Session> 会话对象,不存在返回 nullptr
Here is the caller graph for this function:

◆ forEachSession()

void fix40::SessionManager::forEachSession ( std::function< void(const SessionID &, std::shared_ptr< Session >)>  callback) const

遍历所有会话

Parameters
callback回调函数,参数为 SessionIDSession

◆ getSessionCount()

size_t fix40::SessionManager::getSessionCount ( ) const

获取活跃会话数量

◆ hasSession()

bool fix40::SessionManager::hasSession ( const SessionID sessionID) const

检查会话是否存在

Parameters
sessionID会话标识符

◆ operator=()

SessionManager & fix40::SessionManager::operator= ( const SessionManager )
delete

◆ registerSession()

void fix40::SessionManager::registerSession ( std::shared_ptr< Session session)

注册会话

Parameters
session会话对象

将会话添加到管理器中。如果已存在相同 SessionID 的会话, 会替换旧的会话。

Here is the call graph for this function:

◆ sendMessage()

bool fix40::SessionManager::sendMessage ( const SessionID sessionID,
FixMessage msg 
)

向指定会话发送消息

Parameters
sessionID目标会话标识符
msg要发送的 FIX 消息
Returns
true 发送成功
false 会话不存在或发送失败

此方法会调用 Session::send_app_message(), 触发 Application::toApp() 回调。

Here is the call graph for this function:

◆ unregisterSession()

bool fix40::SessionManager::unregisterSession ( const SessionID sessionID)

注销会话

Parameters
sessionID会话标识符
Returns
true 成功注销
false 会话不存在
Here is the call graph for this function:

The documentation for this class was generated from the following files: