WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
|
#include <webcface/internal/client_internal.h>
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 SharedString & | getMemberNameFromId (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::ImageReq > | image_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 |
|
explicit |
void close | ( | ) |
|
inline |
|
inline |
|
inline |
void join | ( | ) |
threadを待機 (close時)
|
inline |
接続中かどうかに関係なくメッセージをキューに入れる
syncで確実に送信するデータに使う。
|
inline |
|
inline |
接続中の場合メッセージをキューに入れtrueを返し、 接続していない場合なにもせずfalseを返す
Call, Pingなど
|
inline |
sync_firstが空でなければメッセージをキューに入れtrueを返し、 sync_firstが空ならなにもせずfalseを返す
Reqはsync_first時にすべて含まれるので。
void onRecv | ( | const std::vector< std::pair< int, std::shared_ptr< void > > > & | messages | ) |
受信時の処理
std::string packSyncData | ( | std::stringstream & | buffer, |
int & | len, | ||
const SyncDataSnapshot & | data | ||
) |
std::string packSyncDataFirst | ( | const SyncDataFirst & | data | ) |
void pingStatusReq | ( | ) |
ping_status_reqをtrueにしmessage_queueに投げる
void start | ( | ) |
通信関係のスレッドを開始する
void syncImpl | ( | bool | sync, |
bool | forever, | ||
std::optional< std::chrono::microseconds > | timeout | ||
) |
recv_queueのメッセージを処理する
std::atomic<bool> auto_reconnect = true |
ただの設定フラグなのでmutexやcondとは無関係
SyncDataStore2<std::shared_ptr<message::Canvas2DData> > canvas2d_store |
SyncDataStore2<std::shared_ptr<message::Canvas3DData> > canvas3d_store |
std::atomic<bool> closing = false |
\brief recv_queueのメッセージを処理するスレッド auto_recv がtrueの場合のみ。 ‍/
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、すべてのスレッドは停止する
std::shared_ptr<void> curl_initializer |
bool current_curl_connected = false |
void* current_curl_handle = nullptr |
std::string current_curl_path |
std::string current_ws_buf = "" |
std::mutex entry_m |
std::mutex event_m |
コールバックリスト(のmapなど)にアクセスするときにロック
StrMap1<Queue<FuncCallHandle> > func_listener_handlers |
listenerがfetchするの待ちの関数呼び出しをためておく
FuncResultStore func_result_store |
SyncDataStore2<std::shared_ptr<FuncData> > func_store |
SharedString host |
SyncDataStore2<ImageData, message::ImageReq> image_store |
SyncDataStore2<std::shared_ptr<LogData> > log_store |
StrMap1<std::unique_ptr<std::streambuf> > logger_buf |
StrMap1<std::unique_ptr<std::wstreambuf> > logger_buf_w |
std::shared_ptr<spdlog::logger> logger_internal |
std::mutex logger_m |
StrMap1<std::unique_ptr<std::ostream> > logger_os |
StrMap1<std::unique_ptr<std::wostream> > logger_os_w |
std::unordered_map<unsigned int, std::string> member_addr |
StrSet1 member_entry |
std::shared_ptr<std::function<void(Member)> > member_entry_event |
各種イベントはコールバックを登録しようとした時(EventTargetの初期化時) にはじめて初期化する。
なのでmapになっていないmember_entry_eventもnullの可能性がある
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::shared_ptr<std::unordered_map<unsigned int, int> > ping_status |
bool ping_status_req = false |
int port |
StrMap2<std::shared_ptr<std::function<void(RobotModel)> > > robot_model_change_event |
StrMap1<std::shared_ptr<std::function<void(RobotModel)> > > robot_model_entry_event |
SyncDataStore2<std::shared_ptr<RobotModelData> > robot_model_store |
std::optional<unsigned int> self_member_id |
SharedString self_member_name |
Client自身の名前
std::string svr_hostname |
std::string svr_name |
std::string svr_version |
SyncDataStore1<std::chrono::system_clock::time_point> sync_time_store |
SyncDataStore2<std::shared_ptr<TextData> > text_store |
SyncDataStore2<std::shared_ptr<ValueData> > value_store |
SyncDataStore2<std::shared_ptr<message::ViewData> > view_store |
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する
std::thread ws_thread |
websocket接続、通信するスレッド