Samchon Framework for CPP
1.0.0
|
#include <Server.hpp>
Public Member Functions | |
Server () | |
virtual | ~Server ()=default |
auto | has (const std::string &accountID) const -> bool |
auto | get (const std::string &accountID) const -> std::shared_ptr< User > |
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::protocol::WebServer | |
WebServer () | |
Public Member Functions inherited from samchon::protocol::Server | |
Server () | |
virtual void | open (int port) |
virtual void | close () |
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 | createUser () -> User *=0 |
Protected Member Functions inherited from samchon::protocol::Server | |
virtual void | addClient (std::shared_ptr< ClientDriver >)=0 |
Private Member Functions | |
virtual void | addClient (std::shared_ptr< protocol::ClientDriver > driver) final |
A cloud server.
The Server is an abstract server class, who can build a real-time cloud server, that is following the web-socket protocol. Extends this Server and related classes and overrides abstract methods under below. After the overridings, open this cloud server using the open() method.
Definition at line 51 of file Server.hpp.
|
inline |
Default Constructor.
Definition at line 73 of file Server.hpp.
References createUser(), and ~Server().
|
virtualdefault |
Default Destructor.
Reimplemented from samchon::protocol::Server.
Referenced by Server().
|
protectedpure virtual |
Factory method creating User object.
Referenced by addClient(), and Server().
|
inline |
Test wheter an User exists with the accountID.
accountID | Account id of User to find. |
Definition at line 101 of file Server.hpp.
References samchon::HashMap< Key, T, Hash, Pred, Alloc >::has().
|
inline |
Get an User object by its accountID.
accountID | Account id of User to get. |
Definition at line 112 of file Server.hpp.
References samchon::HashMap< Key, T, Hash, Pred, Alloc >::get().
|
inlineoverridevirtual |
Send an Invoke message.
Sends an Invoke message to all remote clients through the belonged User and Client objects. Sending the Invoke message to all remote clients, it's came true by passing through User.sendData(). And the User.sendData also pass through the Client.sendData().
invoke | Invoke message to send to all remote clients. |
Definition at line 142 of file Server.hpp.
References replyData(), samchon::templates::service::User::sendData(), and samchon::library::UniqueReadLock::unlock().
|
pure virtual |
Handle a replied Invoke message.
The Server.replyData() is an abstract method that handling Invoke message that should be handled in the Server level. Overrides this replyData() method and defines what to do with the Invoke message in this Server level.
Referenced by sendData().
|
inlinefinalprivatevirtual |
Add a newly connected remote client.
When a remote client connects to this cloud server, then Server queries the {WebClientDriver.getSessionID session id} of the remote client. If the {WebClientDriver.getSessionID session id} is new one, then creates a new User object.
At next, creates a Client object who represents the newly connected remote client and insert the Client object to the matched User object which is new or ordinary one following the {WebClientDriver.getSessionID session id}. At last, a Service object can be created with referencing the path.
List of objects can be created by this method.
driver | A web communicator for remote client. |
Definition at line 190 of file Server.hpp.
References createUser(), and samchon::protocol::WebClientDriver::getSessionID().