Samchon Framework for CPP  1.0.0
samchon::templates::service::Server Class Referenceabstract

#include <Server.hpp>

Collaboration diagram for samchon::templates::service::Server:

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
 

Detailed Description

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.

Class Diagram

Templates - Cloud Service

Author
Jeongho Nam http://samchon.org

Definition at line 51 of file Server.hpp.

Constructor & Destructor Documentation

samchon::templates::service::Server::Server ( )
inline

Default Constructor.

Definition at line 73 of file Server.hpp.

References createUser(), and ~Server().

Here is the call graph for this function:

virtual samchon::templates::service::Server::~Server ( )
virtualdefault

Default Destructor.

Reimplemented from samchon::protocol::Server.

Referenced by Server().

Here is the caller graph for this function:

Member Function Documentation

virtual auto samchon::templates::service::Server::createUser ( ) -> User *
protectedpure virtual

Factory method creating User object.

Returns
A newly created User object.

Referenced by addClient(), and Server().

Here is the caller graph for this function:

auto samchon::templates::service::Server::has ( const std::string &  accountID) const -> bool
inline

Test wheter an User exists with the accountID.

Parameters
accountIDAccount id of User to find.
Returns
Exists or not.

Definition at line 101 of file Server.hpp.

References samchon::HashMap< Key, T, Hash, Pred, Alloc >::has().

Here is the call graph for this function:

auto samchon::templates::service::Server::get ( const std::string &  accountID) const -> std::shared_ptr<User>
inline

Get an User object by its accountID.

Parameters
accountIDAccount id of User to get.
Returns
An User object.

Definition at line 112 of file Server.hpp.

References samchon::HashMap< Key, T, Hash, Pred, Alloc >::get().

Here is the call graph for this function:

virtual void samchon::templates::service::Server::sendData ( std::shared_ptr< protocol::Invoke invoke)
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().

1 class protocol.service.Server
2 {
3  public sendData(invoke: Invoke): void
4  {
5  for (user: User in this)
6  for (client: Client in user)
7  client.sendData(invoke);
8  }
9 }
Parameters
invokeInvoke 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().

Here is the call graph for this function:

virtual void samchon::templates::service::Server::replyData ( std::shared_ptr< protocol::Invoke )
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.

Parameters
invokeAn invoke message to be handled in Server level.

Referenced by sendData().

Here is the caller graph for this function:

virtual void samchon::templates::service::Server::addClient ( std::shared_ptr< protocol::ClientDriver driver)
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.

Parameters
driverA web communicator for remote client.

Definition at line 190 of file Server.hpp.

References createUser(), and samchon::protocol::WebClientDriver::getSessionID().

Here is the call graph for this function:


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