RunicVTT Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
Message.h File Reference
#include <string>
#include <string_view>
#include <cstdint>
#include "nlohmann/json.hpp"
#include "Components.h"
Include dependency graph for Message.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  msg::MarkerMeta
 
struct  msg::BoardMeta
 
struct  msg::ReadyMessage
 
struct  msg::NetEvent
 
struct  msg::InboundRaw
 

Namespaces

namespace  msg
 
namespace  msg::key
 
namespace  msg::signaling
 
namespace  msg::value
 
namespace  msg::dc
 
namespace  msg::dc::name
 
namespace  msg::chatkey
 

Typedefs

using msg::Json = nlohmann::json
 

Enumerations

enum class  Role { NONE , GAMEMASTER , PLAYER }
 
enum class  ConnectionType { EXTERNAL , LOCAL , LOCALTUNNEL , CUSTOM }
 
enum class  msg::DCType : uint8_t {
  msg::Snapshot_GameTable = 100 , msg::Snapshot_Board = 101 , msg::CommitMarker = 102 , msg::CommitBoard = 103 ,
  msg::ImageChunk = 104 , msg::MarkerMove = 150 , msg::MarkerMoveState = 151 , msg::MarkerCreate = 1 ,
  msg::MarkerUpdate = 2 , msg::MarkerDelete = 3 , msg::FogCreate = 4 , msg::FogUpdate = 5 ,
  msg::FogDelete = 6 , msg::GridUpdate = 7 , msg::NoteCreate = 8 , msg::NoteUpdate = 9 ,
  msg::NoteDelete = 10 , msg::UserNameUpdate = 105 , msg::ChatGroupCreate = 200 , msg::ChatGroupUpdate = 201 ,
  msg::ChatGroupDelete = 202 , msg::ChatMessage = 203
}
 
enum class  msg::ImageOwnerKind : uint8_t { msg::Board = 0 , msg::Marker = 1 }
 

Functions

std::string msg::DCtypeString (DCType type)
 
const char * msg::DCTypeToJson (DCType t)
 
bool msg::DCTypeFromJson (std::string_view s, DCType &out)
 
Json msg::makeChatGroupCreate (uint64_t tableId, uint64_t groupId, const std::string &name, const std::set< std::string > &participants)
 
Json msg::makeChatGroupUpdate (uint64_t tableId, uint64_t groupId, const std::string &name, const std::set< std::string > &participants)
 
Json msg::makeChatGroupDelete (uint64_t tableId, uint64_t groupId)
 
Json msg::makeChatMessage (uint64_t tableId, uint64_t groupId, uint64_t ts, const std::string &username, const std::string &text)
 
Json msg::makeOffer (const std::string &from, const std::string &to, const std::string &sdp, const std::string &username, const std::string &uniqueId, const std::string &broadcast=msg::value::False)
 
Json msg::makeAnswer (const std::string &from, const std::string &to, const std::string &sdp, const std::string &username, const std::string &uniqueId, const std::string &broadcast=msg::value::False)
 
Json msg::makeCandidate (const std::string &from, const std::string &to, const std::string &cand, const std::string &broadcast=msg::value::False)
 
Json msg::makePresence (const std::string &event, const std::string &clientId)
 
nlohmann::json msg::makePeerDisconnect (const std::string &targetPeerId, bool broadcast=true)
 
Json msg::makeBroadcastShutdown ()
 
Json msg::makePing (const std::string &from)
 
Json msg::makeAuth (const std::string &token, const std::string &username, const std::string &uniqueId)
 
nlohmann::json msg::makeAuthResponse (const std::string ok, const std::string &msg, const std::string &clientId, const std::string &username, const std::vector< std::string > &clients={}, const std::string &gmPeerId="", const std::string &uniqueId="")
 
Json msg::makeText (const std::string &from, const std::string &to, const std::string &text, bool broadcast=false)
 
bool msg::isType (const Json &j, std::string t)
 
std::string msg::getString (const Json &j, std::string k, std::string def={})
 
int msg::getInt (const Json &j, std::string k, int def=0)
 
bool msg::getBool (const Json &j, std::string k, bool def=false)
 

Variables

constexpr std::string_view msg::key::Type = "type"
 
constexpr std::string_view msg::key::From = "from"
 
constexpr std::string_view msg::key::To = "to"
 
constexpr std::string_view msg::key::Broadcast = "broadcast"
 
constexpr std::string_view msg::key::Timestamp = "ts"
 
constexpr std::string_view msg::key::Text = "text"
 
constexpr std::string_view msg::key::Clients = "clients"
 
constexpr std::string_view msg::key::Event = "event"
 
constexpr std::string_view msg::key::Username = "username"
 
constexpr std::string_view msg::key::ClientId = "clientId"
 
constexpr std::string_view msg::key::Target = "target"
 
constexpr std::string_view msg::key::GmId = "gmId"
 
constexpr std::string_view msg::key::Sdp = "sdp"
 
constexpr std::string_view msg::key::Candidate = "candidate"
 
constexpr std::string_view msg::key::SdpMid = "sdpMid"
 
constexpr std::string_view msg::key::UniqueId = "uniqueId"
 
constexpr std::string_view msg::key::AuthOk = "ok"
 
constexpr std::string_view msg::key::AuthMsg = "msg"
 
constexpr std::string_view msg::key::AuthToken = "token"
 
constexpr std::string_view msg::key::Password = "password"
 
constexpr std::string_view msg::key::Label = "label"
 
constexpr std::string_view msg::key::Payload = "payload"
 
constexpr std::string_view msg::key::EntityId = "entityId"
 
constexpr std::string_view msg::key::X = "x"
 
constexpr std::string_view msg::key::Y = "y"
 
constexpr std::string_view msg::key::Z = "z"
 
constexpr std::string_view msg::key::Visible = "visible"
 
constexpr std::string_view msg::key::ImageId = "imageId"
 
constexpr std::string_view msg::key::BytesOffset = "offset"
 
constexpr std::string_view msg::key::BytesTotal = "total"
 
constexpr std::string_view msg::key::Chunk = "chunk"
 
constexpr std::string_view msg::signaling::Join = "join"
 
constexpr std::string_view msg::signaling::Offer = "offer"
 
constexpr std::string_view msg::signaling::Answer = "answer"
 
constexpr std::string_view msg::signaling::Presence = "presence"
 
constexpr std::string_view msg::signaling::Candidate = "candidate"
 
constexpr std::string_view msg::signaling::Ping = "ping"
 
constexpr std::string_view msg::signaling::Pong = "pong"
 
constexpr std::string_view msg::signaling::Auth = "auth"
 
constexpr std::string_view msg::signaling::AuthResponse = "auth_response"
 
constexpr std::string_view msg::signaling::Text = "text"
 
constexpr std::string_view msg::signaling::ServerDisconnect = "server_disconnect"
 
constexpr std::string_view msg::signaling::PeerDisconnect = "peer_disconnect"
 
constexpr std::string msg::value::False = "false"
 
constexpr std::string msg::value::True = "true"
 
constexpr std::string msg::dc::name::Game = "game"
 
constexpr std::string msg::dc::name::Chat = "chat"
 
constexpr std::string msg::dc::name::Notes = "notes"
 
constexpr std::string msg::dc::name::MarkerMove = "marker_move"
 
constexpr std::string_view msg::chatkey::Type = "type"
 
constexpr std::string_view msg::chatkey::TableId = "tableId"
 
constexpr std::string_view msg::chatkey::GroupId = "groupId"
 
constexpr std::string_view msg::chatkey::Name = "name"
 
constexpr std::string_view msg::chatkey::Parts = "participants"
 
constexpr std::string_view msg::chatkey::Ts = "ts"
 
constexpr std::string_view msg::chatkey::Username = "username"
 
constexpr std::string_view msg::chatkey::Text = "text"
 

Enumeration Type Documentation

◆ ConnectionType

enum class ConnectionType
strong
Enumerator
EXTERNAL 
LOCAL 
LOCALTUNNEL 
CUSTOM 

Definition at line 19 of file Message.h.

◆ Role

enum class Role
strong
Enumerator
NONE 
GAMEMASTER 
PLAYER 

Definition at line 12 of file Message.h.

13{
14 NONE,
16 PLAYER
17};
@ PLAYER
@ GAMEMASTER