yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::net::CollaborationService Class Reference

High-level service integrating version management with networking. More...

#include <collaboration_service.h>

Collaboration diagram for yaze::net::CollaborationService:

Classes

struct  Config
 

Public Member Functions

 CollaborationService (Rom *rom)
 
 ~CollaborationService ()
 
absl::Status Initialize (const Config &config, RomVersionManager *version_mgr, ProposalApprovalManager *approval_mgr)
 
absl::Status Connect (const std::string &host, int port=8765)
 
void Disconnect ()
 
absl::Status HostSession (const std::string &session_name, const std::string &username, bool ai_enabled=true)
 
absl::Status JoinSession (const std::string &session_code, const std::string &username)
 
absl::Status LeaveSession ()
 
absl::Status SubmitChangesAsProposal (const std::string &description, const std::string &username)
 
absl::Status ApplyRomSync (const std::string &diff_data, const std::string &rom_hash, const std::string &sender)
 
absl::Status HandleIncomingProposal (const std::string &proposal_id, const nlohmann::json &proposal_data, const std::string &sender)
 
absl::Status VoteOnProposal (const std::string &proposal_id, bool approved, const std::string &username)
 
absl::Status ApplyApprovedProposal (const std::string &proposal_id)
 
bool IsConnected () const
 
absl::StatusOr< SessionInfoGetSessionInfo () const
 
WebSocketClientGetClient ()
 
void SetAutoSync (bool enabled)
 

Private Member Functions

void OnRomSyncReceived (const nlohmann::json &payload)
 
void OnProposalReceived (const nlohmann::json &payload)
 
void OnProposalUpdated (const nlohmann::json &payload)
 
void OnParticipantJoined (const nlohmann::json &payload)
 
void OnParticipantLeft (const nlohmann::json &payload)
 
std::string GenerateDiff (const std::string &from_hash, const std::string &to_hash)
 
absl::Status ApplyDiff (const std::string &diff_data)
 
bool ShouldAutoSync ()
 

Private Attributes

Romrom_
 
RomVersionManagerversion_mgr_
 
ProposalApprovalManagerapproval_mgr_
 
std::unique_ptr< WebSocketClientclient_
 
Config config_
 
std::string last_sync_hash_
 
bool sync_in_progress_
 

Detailed Description

High-level service integrating version management with networking.

Bridges the gap between:

  • Local ROM version management
  • Remote collaboration via WebSocket
  • Proposal approval workflow

Features:

  • Automatic ROM sync on changes
  • Network-aware proposal approval
  • Conflict resolution
  • Auto-backup before network operations

Definition at line 32 of file collaboration_service.h.

Constructor & Destructor Documentation

◆ CollaborationService()

yaze::net::CollaborationService::CollaborationService ( Rom rom)
explicit

Definition at line 12 of file collaboration_service.cc.

◆ ~CollaborationService()

yaze::net::CollaborationService::~CollaborationService ( )

Definition at line 20 of file collaboration_service.cc.

References Disconnect().

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

absl::Status yaze::net::CollaborationService::Initialize ( const Config config,
RomVersionManager version_mgr,
ProposalApprovalManager approval_mgr 
)

◆ Connect()

absl::Status yaze::net::CollaborationService::Connect ( const std::string &  host,
int  port = 8765 
)

Connect to collaboration server

Definition at line 74 of file collaboration_service.cc.

References client_.

◆ Disconnect()

void yaze::net::CollaborationService::Disconnect ( )

Disconnect from server

Definition at line 78 of file collaboration_service.cc.

References client_.

Referenced by ~CollaborationService().

◆ HostSession()

absl::Status yaze::net::CollaborationService::HostSession ( const std::string &  session_name,
const std::string &  username,
bool  ai_enabled = true 
)

◆ JoinSession()

absl::Status yaze::net::CollaborationService::JoinSession ( const std::string &  session_code,
const std::string &  username 
)

◆ LeaveSession()

absl::Status yaze::net::CollaborationService::LeaveSession ( )

Leave current session

Definition at line 163 of file collaboration_service.cc.

References client_.

◆ SubmitChangesAsProposal()

absl::Status yaze::net::CollaborationService::SubmitChangesAsProposal ( const std::string &  description,
const std::string &  username 
)

◆ ApplyRomSync()

absl::Status yaze::net::CollaborationService::ApplyRomSync ( const std::string &  diff_data,
const std::string &  rom_hash,
const std::string &  sender 
)

◆ HandleIncomingProposal()

absl::Status yaze::net::CollaborationService::HandleIncomingProposal ( const std::string &  proposal_id,
const nlohmann::json &  proposal_data,
const std::string &  sender 
)

Handle incoming proposal

Definition at line 259 of file collaboration_service.cc.

References approval_mgr_, and yaze::net::ProposalApprovalManager::SubmitProposal().

Referenced by OnProposalReceived().

Here is the call graph for this function:

◆ VoteOnProposal()

absl::Status yaze::net::CollaborationService::VoteOnProposal ( const std::string &  proposal_id,
bool  approved,
const std::string &  username 
)

Vote on proposal

Definition at line 277 of file collaboration_service.cc.

References approval_mgr_, client_, and yaze::net::ProposalApprovalManager::VoteOnProposal().

Here is the call graph for this function:

◆ ApplyApprovedProposal()

absl::Status yaze::net::CollaborationService::ApplyApprovedProposal ( const std::string &  proposal_id)

◆ IsConnected()

bool yaze::net::CollaborationService::IsConnected ( ) const

Get connection status

Definition at line 325 of file collaboration_service.cc.

References client_.

◆ GetSessionInfo()

absl::StatusOr< SessionInfo > yaze::net::CollaborationService::GetSessionInfo ( ) const

Get session info

Definition at line 329 of file collaboration_service.cc.

References client_.

◆ GetClient()

WebSocketClient * yaze::net::CollaborationService::GetClient ( )
inline

Get WebSocket client (for advanced usage)

Definition at line 131 of file collaboration_service.h.

References client_.

◆ SetAutoSync()

void yaze::net::CollaborationService::SetAutoSync ( bool  enabled)

Enable/disable auto-sync

Definition at line 333 of file collaboration_service.cc.

References yaze::net::CollaborationService::Config::auto_sync_enabled, and config_.

◆ OnRomSyncReceived()

void yaze::net::CollaborationService::OnRomSyncReceived ( const nlohmann::json &  payload)
private

Definition at line 339 of file collaboration_service.cc.

References ApplyRomSync().

Referenced by Initialize().

Here is the call graph for this function:

◆ OnProposalReceived()

void yaze::net::CollaborationService::OnProposalReceived ( const nlohmann::json &  payload)
private

Definition at line 351 of file collaboration_service.cc.

References HandleIncomingProposal().

Referenced by Initialize().

Here is the call graph for this function:

◆ OnProposalUpdated()

void yaze::net::CollaborationService::OnProposalUpdated ( const nlohmann::json &  payload)
private

Definition at line 359 of file collaboration_service.cc.

References approval_mgr_.

Referenced by Initialize().

◆ OnParticipantJoined()

void yaze::net::CollaborationService::OnParticipantJoined ( const nlohmann::json &  payload)
private

Definition at line 378 of file collaboration_service.cc.

Referenced by Initialize().

◆ OnParticipantLeft()

void yaze::net::CollaborationService::OnParticipantLeft ( const nlohmann::json &  payload)
private

Definition at line 383 of file collaboration_service.cc.

Referenced by Initialize().

◆ GenerateDiff()

std::string yaze::net::CollaborationService::GenerateDiff ( const std::string &  from_hash,
const std::string &  to_hash 
)
private
Todo:
Implement proper binary diff generation

Definition at line 390 of file collaboration_service.cc.

References yaze::Rom::is_loaded(), and rom_.

Referenced by SubmitChangesAsProposal().

Here is the call graph for this function:

◆ ApplyDiff()

absl::Status yaze::net::CollaborationService::ApplyDiff ( const std::string &  diff_data)
private
Todo:
Implement proper diff application

Definition at line 408 of file collaboration_service.cc.

References yaze::Rom::is_loaded(), and rom_.

Referenced by ApplyRomSync().

Here is the call graph for this function:

◆ ShouldAutoSync()

bool yaze::net::CollaborationService::ShouldAutoSync ( )
private

Member Data Documentation

◆ rom_

Rom* yaze::net::CollaborationService::rom_
private

◆ version_mgr_

RomVersionManager* yaze::net::CollaborationService::version_mgr_
private

◆ approval_mgr_

ProposalApprovalManager* yaze::net::CollaborationService::approval_mgr_
private

◆ client_

◆ config_

Config yaze::net::CollaborationService::config_
private

◆ last_sync_hash_

std::string yaze::net::CollaborationService::last_sync_hash_
private

◆ sync_in_progress_

bool yaze::net::CollaborationService::sync_in_progress_
private

Definition at line 147 of file collaboration_service.h.

Referenced by ApplyRomSync(), and ShouldAutoSync().


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