Samchon Framework for CPP
1.0.0
|
#include <User.hpp>
Public Member Functions | |
User (Server *server) | |
virtual | ~User ()=default |
auto | getServer () const -> Server * |
auto | getAccount () const -> std::string |
auto | getAuthority () const -> int |
void | setAccount (const std::string &account, int authority) |
void | logout () |
virtual void | sendData (std::shared_ptr< protocol::Invoke > invoke) override |
virtual void | replyData (std::shared_ptr< protocol::Invoke >)=0 |
Public Member Functions inherited from samchon::TreeMap< size_t, std::shared_ptr< Client > > | |
auto | has (const size_t &key) const -> bool |
Whether have the item or not. More... | |
auto | get (const size_t &key) -> std::shared_ptr< Client > & |
Get element. More... | |
void | set (const size_t &key, const std::shared_ptr< Client > &val) |
Set element. More... | |
auto | pop (const size_t &key) -> std::shared_ptr< Client > |
Pop item. More... | |
Public Member Functions inherited from samchon::protocol::IProtocol | |
virtual void | replyData (std::shared_ptr< Invoke >)=0 |
virtual void | sendData (std::shared_ptr< Invoke >)=0 |
Protected Member Functions | |
virtual auto | createClient () -> Client *=0 |
An user.
The User is an abstract class groupping Client objects, who communicates with remote client, with same session id. This {link User} represents a remote user literally. Within framework of remote system, an User corresponds to a web-browser and a Client represents a window in the web-browser.
Extends this User class and override the createClient method, a factory method creating a child Client object. I repeat, the User class represents a remote user, groupping Client objects with same session id. If your cloud server has some processes to be handled in the user level, then defines method in this User class. Methods managing account under below are some of them:
The children Client objects, they're contained with their key, the sequence number. If you erase the children Client object by yourself, then their connection with the remote clients will be closed and their destruction method will be called. If you remove all children, then this User object will be also destructed and erased from the parent Server object.
|
inline |
|
virtualdefault |
Default Destructor.
The User object is destructed when connections with the remote clients are all closed, that is all the children Client objects are all removed, and 30 seconds has left. If some remote client connects within the 30 seconds, then the User object doesn't be destructed.
Referenced by User().
|
protectedpure virtual |
|
inline |
|
inline |
|
inline |
|
inline |
Set account id and authority.
The setAccount() is a method configuring account id and authority of this User.
After the configuring, the account id is enrolled into the parent Server as a key for this User object. You can test existence and access this User object from Server.has() and Server.get() with the account id. Of course, if ordinary account id had existed, then the ordinary key will be replaced.
As you suggest, this setAccount() is something like a log-in function. If what you want is not logging-in, but logging-out, then configure the account id to empty string ""
`` or call the logout() method.
id | To be account id. |
authority | To be authority. |
|
inline |
Log-out.
This logout() method configures account id to empty string and authority to zero.
The ordinary account id will be also erased from the parent Server object. You can't access this User object from Server.has() and Server.get() with the ordinary account id more.
|
inlineoverridevirtual |
Send an Invoke message.
Sends an Invoke message to all remote clients through the belonged Client objects. Sending the Invoke message to all remote clients, it's came true by passing through the Client.sendData() methods.
invoke | Invoke message to send to all remote clients. |
Definition at line 229 of file User.hpp.
References replyData(), samchon::templates::service::Client::sendData(), and samchon::library::UniqueReadLock::unlock().
Referenced by samchon::templates::service::Server::sendData().
|
pure virtual |
Handle a replied Invoke message.
The default User.replyData() shifts chain to its parent Server object, by calling the Server.replyData() method. If there're some Invoke message to be handled in this User level, then override this method and defines what to do with the Invoke message in this User level.
Referenced by sendData().