WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
ClientData Struct Reference

#include <webcface/internal/client_internal.h>

Inheritance diagram for ClientData:
[legend]
Collaboration diagram for ClientData:
[legend]

Classes

class  ScopedSyncLock
 
class  ScopedWsLock
 
struct  SyncMutexedData
 
struct  WsMutexedData
 

Public Member Functions

 ClientData (const SharedString &name, const SharedString &host=nullptr, int port=-1)
 
void close ()
 
bool isSelf (const FieldBase &base) const
 
bool messagePushOnline (std::string &&msg)
 
bool messagePushReq (std::string &&msg)
 
void messagePushAlways (std::string &&msg)
 
void messagePushAlways (SyncDataSnapshot &&msg)
 
std::string packSyncDataFirst (const SyncDataFirst &data)
 
std::string packSyncData (std::stringstream &buffer, int &len, const SyncDataSnapshot &data)
 
void start ()
 通信関係のスレッドを開始する
 
void join ()
 threadを待機 (close時)
 
void syncImpl (bool sync, bool forever, std::optional< std::chrono::microseconds > timeout)
 recv_queueのメッセージを処理する
 
void onRecv (const std::vector< std::pair< int, std::shared_ptr< void > > > &messages)
 受信時の処理
 
const SharedStringgetMemberNameFromId (unsigned int id) const
 
unsigned int getMemberIdFromName (const SharedString &name) const
 
void pingStatusReq ()
 ping_status_reqをtrueにしmessage_queueに投げる
 

Public Attributes

SharedString self_member_name
 Client自身の名前
 
std::optional< unsigned int > self_member_id
 
SharedString host
 
int port
 
bool current_curl_connected = false
 
void * current_curl_handle = nullptr
 
std::string current_curl_path
 
std::string current_ws_buf = ""
 
std::shared_ptr< void > curl_initializer
 
std::thread ws_thread
 websocket接続、通信するスレッド
 
std::atomic< bool > closing = false
 
std::condition_variable ws_cond
 ws_thread, recv_thread, queue 間の同期
 
std::atomic< bool > auto_reconnect = true
 
std::mutex entry_m
 
StrSet1 member_entry
 
SyncDataStore2< std::shared_ptr< ValueData > > value_store
 
SyncDataStore2< std::shared_ptr< TextData > > text_store
 
SyncDataStore2< std::shared_ptr< FuncData > > func_store
 
SyncDataStore2< std::shared_ptr< message::ViewData > > view_store
 
SyncDataStore2< ImageData, message::ImageReqimage_store
 
SyncDataStore2< std::shared_ptr< RobotModelData > > robot_model_store
 
SyncDataStore2< std::shared_ptr< message::Canvas3DData > > canvas3d_store
 
SyncDataStore2< std::shared_ptr< message::Canvas2DData > > canvas2d_store
 
SyncDataStore2< std::shared_ptr< LogData > > log_store
 
SyncDataStore1< std::chrono::system_clock::time_point > sync_time_store
 
FuncResultStore func_result_store
 
StrMap1< Queue< FuncCallHandle > > func_listener_handlers
 listenerがfetchするの待ちの関数呼び出しをためておく
 
StrMap1< unsigned int > member_ids
 
std::unordered_map< unsigned int, std::string > member_lib_name
 
std::unordered_map< unsigned int, std::string > member_lib_ver
 
std::unordered_map< unsigned int, std::string > member_addr
 
std::mutex event_m
 コールバックリスト(のmapなど)にアクセスするときにロック
 
std::shared_ptr< std::function< void(Member)> > member_entry_event
 
StrMap2< std::shared_ptr< std::function< void(Value)> > > value_change_event
 
StrMap2< std::shared_ptr< std::function< void(Variant)> > > text_change_event
 
StrMap2< std::shared_ptr< std::function< void(Image)> > > image_change_event
 
StrMap2< std::shared_ptr< std::function< void(RobotModel)> > > robot_model_change_event
 
StrMap2< std::shared_ptr< std::function< void(View)> > > view_change_event
 
StrMap2< std::shared_ptr< std::function< void(Canvas3D)> > > canvas3d_change_event
 
StrMap2< std::shared_ptr< std::function< void(Canvas2D)> > > canvas2d_change_event
 
StrMap2< std::shared_ptr< std::function< void(Log)> > > log_append_event
 
StrMap1< std::shared_ptr< std::function< void(Member)> > > sync_event
 
StrMap1< std::shared_ptr< std::function< void(Member)> > > ping_event
 
StrMap1< std::shared_ptr< std::function< void(Value)> > > value_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Text)> > > text_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Func)> > > func_entry_event
 
StrMap1< std::shared_ptr< std::function< void(View)> > > view_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Image)> > > image_entry_event
 
StrMap1< std::shared_ptr< std::function< void(RobotModel)> > > robot_model_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Canvas3D)> > > canvas3d_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Canvas2D)> > > canvas2d_entry_event
 
StrMap1< std::shared_ptr< std::function< void(Log)> > > log_entry_event
 
std::shared_ptr< spdlog::logger > logger_internal
 
std::mutex logger_m
 
StrMap1< std::unique_ptr< std::streambuf > > logger_buf
 
StrMap1< std::unique_ptr< std::ostream > > logger_os
 
StrMap1< std::unique_ptr< std::wstreambuf > > logger_buf_w
 
StrMap1< std::unique_ptr< std::wostream > > logger_os_w
 
std::string svr_name
 
std::string svr_version
 
std::string svr_hostname
 
std::shared_ptr< std::unordered_map< unsigned int, int > > ping_status
 
bool ping_status_req = false
 

Constructor & Destructor Documentation

◆ ClientData()

ClientData ( const SharedString name,
const SharedString host = nullptr,
int  port = -1 
)
explicit

Member Function Documentation

◆ close()

void close ( )

◆ getMemberIdFromName()

unsigned int getMemberIdFromName ( const SharedString name) const
inline

◆ getMemberNameFromId()

const SharedString & getMemberNameFromId ( unsigned int  id) const
inline

◆ isSelf()

bool isSelf ( const FieldBase base) const
inline

◆ join()

void join ( )

threadを待機 (close時)

◆ messagePushAlways() [1/2]

void messagePushAlways ( std::string &&  msg)
inline

接続中かどうかに関係なくメッセージをキューに入れる

syncで確実に送信するデータに使う。

◆ messagePushAlways() [2/2]

void messagePushAlways ( SyncDataSnapshot &&  msg)
inline

◆ messagePushOnline()

bool messagePushOnline ( std::string &&  msg)
inline

接続中の場合メッセージをキューに入れtrueを返し、 接続していない場合なにもせずfalseを返す

Call, Pingなど

◆ messagePushReq()

bool messagePushReq ( std::string &&  msg)
inline

sync_firstが空でなければメッセージをキューに入れtrueを返し、 sync_firstが空ならなにもせずfalseを返す

Reqはsync_first時にすべて含まれるので。

◆ onRecv()

void onRecv ( const std::vector< std::pair< int, std::shared_ptr< void > > > &  messages)

受信時の処理

◆ packSyncData()

std::string packSyncData ( std::stringstream &  buffer,
int &  len,
const SyncDataSnapshot &  data 
)

◆ packSyncDataFirst()

std::string packSyncDataFirst ( const SyncDataFirst &  data)

◆ pingStatusReq()

void pingStatusReq ( )

ping_status_reqをtrueにしmessage_queueに投げる

◆ start()

void start ( )

通信関係のスレッドを開始する

◆ syncImpl()

void syncImpl ( bool  sync,
bool  forever,
std::optional< std::chrono::microseconds >  timeout 
)

recv_queueのメッセージを処理する

  • メッセージがなければtimeout後にreturn
  • auto_reconnectがfalseで接続できてない場合はreturn (deadlock回避)
  • timeoutがnulloptならclosingまで永遠にreturnしない

Member Data Documentation

◆ auto_reconnect

std::atomic<bool> auto_reconnect = true

ただの設定フラグなのでmutexやcondとは無関係

◆ canvas2d_change_event

StrMap2<std::shared_ptr<std::function<void(Canvas2D)> > > canvas2d_change_event

◆ canvas2d_entry_event

StrMap1<std::shared_ptr<std::function<void(Canvas2D)> > > canvas2d_entry_event

◆ canvas2d_store

SyncDataStore2<std::shared_ptr<message::Canvas2DData> > canvas2d_store

◆ canvas3d_change_event

StrMap2<std::shared_ptr<std::function<void(Canvas3D)> > > canvas3d_change_event

◆ canvas3d_entry_event

StrMap1<std::shared_ptr<std::function<void(Canvas3D)> > > canvas3d_entry_event

◆ canvas3d_store

SyncDataStore2<std::shared_ptr<message::Canvas3DData> > canvas3d_store

◆ closing

std::atomic<bool> closing = false
      \brief recv_queueのメッセージを処理するスレッド

      auto_recv がtrueの場合のみ。

     &zwj;/

std::thread sync_thread;

struct SyncDataSnapshot {
    std::chrono::system_clock::time_point time;
    StrMap1<std::shared_ptr<ValueData>> value_data;
    StrMap1<std::shared_ptr<TextData>> text_data;
    StrMap1<std::shared_ptr<RobotModelData>> robot_model_data;
    StrMap1<std::shared_ptr<message::ViewData>> view_prev, view_data;
    StrMap1<std::shared_ptr<message::Canvas3DData>> canvas3d_prev, canvas3d_data;
    StrMap1<std::shared_ptr<message::Canvas2DData>> canvas2d_prev, canvas2d_data;
    StrMap1<ImageData> image_data;
    StrMap1<std::vector<LogLineData>> log_data;
    StrMap1<std::shared_ptr<FuncData>> func_data;
};

struct SyncDataFirst {
    StrMap2<unsigned int> value_req, text_req, robot_model_req, view_req,
        canvas3d_req, canvas2d_req, image_req, log_req;
    StrMap2<message::ImageReq> image_req_info;
    bool ping_status_req;
    SyncDataSnapshot sync_data;
};

/*!
   close()が呼ばれたらtrue、すべてのスレッドは停止する

◆ curl_initializer

std::shared_ptr<void> curl_initializer

◆ current_curl_connected

bool current_curl_connected = false

◆ current_curl_handle

void* current_curl_handle = nullptr

◆ current_curl_path

std::string current_curl_path

◆ current_ws_buf

std::string current_ws_buf = ""

◆ entry_m

std::mutex entry_m

◆ event_m

std::mutex event_m

コールバックリスト(のmapなど)にアクセスするときにロック

◆ func_entry_event

StrMap1<std::shared_ptr<std::function<void(Func)> > > func_entry_event

◆ func_listener_handlers

StrMap1<Queue<FuncCallHandle> > func_listener_handlers

listenerがfetchするの待ちの関数呼び出しをためておく

◆ func_result_store

FuncResultStore func_result_store

◆ func_store

SyncDataStore2<std::shared_ptr<FuncData> > func_store

◆ host

◆ image_change_event

StrMap2<std::shared_ptr<std::function<void(Image)> > > image_change_event

◆ image_entry_event

StrMap1<std::shared_ptr<std::function<void(Image)> > > image_entry_event

◆ image_store

◆ log_append_event

StrMap2<std::shared_ptr<std::function<void(Log)> > > log_append_event

◆ log_entry_event

StrMap1<std::shared_ptr<std::function<void(Log)> > > log_entry_event

◆ log_store

SyncDataStore2<std::shared_ptr<LogData> > log_store

◆ logger_buf

StrMap1<std::unique_ptr<std::streambuf> > logger_buf

◆ logger_buf_w

StrMap1<std::unique_ptr<std::wstreambuf> > logger_buf_w

◆ logger_internal

std::shared_ptr<spdlog::logger> logger_internal

◆ logger_m

std::mutex logger_m

◆ logger_os

StrMap1<std::unique_ptr<std::ostream> > logger_os

◆ logger_os_w

StrMap1<std::unique_ptr<std::wostream> > logger_os_w

◆ member_addr

std::unordered_map<unsigned int, std::string> member_addr

◆ member_entry

StrSet1 member_entry

◆ member_entry_event

std::shared_ptr<std::function<void(Member)> > member_entry_event

各種イベントはコールバックを登録しようとした時(EventTargetの初期化時) にはじめて初期化する。

なのでmapになっていないmember_entry_eventもnullの可能性がある

◆ member_ids

StrMap1<unsigned int> member_ids

◆ member_lib_name

std::unordered_map<unsigned int, std::string> member_lib_name

◆ member_lib_ver

std::unordered_map<unsigned int, std::string> member_lib_ver

◆ ping_event

StrMap1<std::shared_ptr<std::function<void(Member)> > > ping_event

◆ ping_status

std::shared_ptr<std::unordered_map<unsigned int, int> > ping_status
Initial value:
=
nullptr

◆ ping_status_req

bool ping_status_req = false

◆ port

int port

◆ robot_model_change_event

StrMap2<std::shared_ptr<std::function<void(RobotModel)> > > robot_model_change_event

◆ robot_model_entry_event

StrMap1<std::shared_ptr<std::function<void(RobotModel)> > > robot_model_entry_event

◆ robot_model_store

SyncDataStore2<std::shared_ptr<RobotModelData> > robot_model_store

◆ self_member_id

std::optional<unsigned int> self_member_id

◆ self_member_name

SharedString self_member_name

Client自身の名前

◆ svr_hostname

std::string svr_hostname

◆ svr_name

std::string svr_name

◆ svr_version

std::string svr_version

◆ sync_event

StrMap1<std::shared_ptr<std::function<void(Member)> > > sync_event

◆ sync_time_store

SyncDataStore1<std::chrono::system_clock::time_point> sync_time_store

◆ text_change_event

StrMap2<std::shared_ptr<std::function<void(Variant)> > > text_change_event

◆ text_entry_event

StrMap1<std::shared_ptr<std::function<void(Text)> > > text_entry_event

◆ text_store

SyncDataStore2<std::shared_ptr<TextData> > text_store

◆ value_change_event

StrMap2<std::shared_ptr<std::function<void(Value)> > > value_change_event

◆ value_entry_event

StrMap1<std::shared_ptr<std::function<void(Value)> > > value_entry_event

◆ value_store

SyncDataStore2<std::shared_ptr<ValueData> > value_store

◆ view_change_event

StrMap2<std::shared_ptr<std::function<void(View)> > > view_change_event

◆ view_entry_event

StrMap1<std::shared_ptr<std::function<void(View)> > > view_entry_event

◆ view_store

SyncDataStore2<std::shared_ptr<message::ViewData> > view_store

◆ ws_cond

std::condition_variable ws_cond

ws_thread, recv_thread, queue 間の同期

ws_dataの中身 (closing, connected, do_ws_init, do_ws_recv, sync_queue, recv_queue, sync_init_end) が変化した時notifyする

◆ ws_thread

std::thread ws_thread

websocket接続、通信するスレッド

  • 未接続状態で do_ws_initがtrue (= start()が呼ばれた) or auto_reconnectがtrueのとき、再接続を行う
  • 接続状態のとき、100usごとに受信したデータを recv_queue に入れ、 sync_queue 内のデータを送信する

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