TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Join.h
1#pragma once
2
3#include <string>
4#include <tt/Role.h>
5#include <tt/io/Message.h>
6
7#ifndef JOIN_H
8#define JOIN_H
9
10namespace tt {
18 class Join: public Message {
19 public:
21 std::string name;
22
28 std::string password;
29
34 std::string world;
35
41
46 std::string partner;
47
62 Join(std::string name, std::string password, std::string world, Role role, std::string partner);
63
64 Join(): role(Role::NONE) {}
65
66 std::string toString() const override;
67
79 bool matches(Join other);
80
81 std::string type() const override {
82 return "Join";
83 }
84
85 private:
87 template <typename T>
88 static const bool matches(const T* o1, const T* o2) {
89 return o1 == nullptr || o2 == nullptr || *o1 == *o2;
90 }
92 };
93
94 void from_json(const nlohmann::json& j, Join& msg);
95 void to_json(nlohmann::json& j, const Join& msg);
96
97}
98
99#endif
The join message is the first message sent from a client to the server to provide the agent's credent...
Definition Join.h:18
std::string name
The new agent's name.
Definition Join.h:21
std::string partner
The name of the partner this new agent wants to play with, or empty if they are willing to play with ...
Definition Join.h:46
std::string type() const override
Type used for JSON deserialization.
Definition Join.h:81
Role role
The role this new agent wants to have in their session, or empty if they are willing to play either r...
Definition Join.h:40
std::string toString() const override
Returns a string representation of this object.
Definition Join.cpp:10
std::string password
The new agent's password, which must be provided if the agent is using a name that is reserved on thi...
Definition Join.h:28
std::string world
The name of the story world this new agent wants to play in, or empty if they are willing to play in ...
Definition Join.h:34
bool matches(Join other)
Returns true if this join request is compatible with another, meaning a session could be created betw...
Definition Join.cpp:23
Join(std::string name, std::string password, std::string world, Role role, std::string partner)
Constructs a new join message with an agent's credentials and preferences.
Definition Join.cpp:6
Message()
Constructs a message.
Definition Message.h:32
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22
Role
Represents the two roles in a collaborative storytelling session: the Player, who typically controls ...
Definition Role.h:16
@ NONE
No role, used as a "null" value.
Definition Role.h:32