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

#include <Client.hpp>

Collaboration diagram for samchon::templates::service::Client:

Public Member Functions

 Client (User *user, std::shared_ptr< protocol::WebClientDriver > driver)
 
virtual ~Client ()=default
 
auto getUser () const -> User *
 
auto getService () const -> Service *
 
auto getNo () const -> size_t
 
void changeService (const std::string &path)
 
void changeService (Service *obj)
 
virtual void sendData (std::shared_ptr< protocol::Invoke > invoke) override
 
virtual void replyData (std::shared_ptr< protocol::Invoke > invoke)
 
- 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 createService (const std::string &) -> Service *=0
 

Detailed Description

A driver of remote client.

The Client is an abstract class representing and interacting with a remote client. It deals the network communication with the remote client and shifts Invoke message to related User and Service objects.

Extends this Client class and override the createService method, a factory method creating a child Service object. Note that, Client represents a remote client, not an user, a specific web page or service. Do not define logics about user or account information. It must be declared in the parent User class. Also, don't define processes of a specific a web page or service. Defines them in the child Service class.

Class Diagram

Templates - Cloud Service

Author
Jeongho Nam http://samchon.org

Definition at line 38 of file Client.hpp.

Constructor & Destructor Documentation

samchon::templates::service::Client::Client ( User user,
std::shared_ptr< protocol::WebClientDriver driver 
)
inline

Construct from parent User and communicator.

Parameters
userParent User object.
driverCommunicator with remote client.

Definition at line 63 of file Client.hpp.

References createService(), and ~Client().

Here is the call graph for this function:

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

Default Destructor.

Client object is destructed when connection with the remote client is closed or this Client object is erased from its parent User object.

Referenced by Client().

Here is the caller graph for this function:

Member Function Documentation

virtual auto samchon::templates::service::Client::createService ( const std::string &  ) -> Service *
protectedpure virtual

Factory method creating Service object.

Parameters
pathRequested path.
Returns
A newly created Service object or null.

Referenced by changeService(), and Client().

Here is the caller graph for this function:

auto samchon::templates::service::Client::getUser ( ) const -> User*
inline

Get parent User object.

Get the parent User object, who is groupping Client objects with same session id.

Returns
The parent User object.

Definition at line 102 of file Client.hpp.

auto samchon::templates::service::Client::getService ( ) const -> Service*
inline

Get child Service object.

Returns
The child Service object.

Definition at line 112 of file Client.hpp.

auto samchon::templates::service::Client::getNo ( ) const -> size_t
inline

Get sequence number.

Get sequence number of this Client object in the parent User object. This sequence number also be a key in the parent User object, who extended the std.HashMap<number, Client>.

Returns
Sequence number.

Definition at line 125 of file Client.hpp.

void samchon::templates::service::Client::changeService ( const std::string &  path)
inline

Change related Service object.

Parameters
pathRequested, identifier path.

Definition at line 135 of file Client.hpp.

References createService().

Here is the call graph for this function:

void samchon::templates::service::Client::changeService ( Service obj)
inline

Change Service to another.

Parameters
serviceservice object to newly assigned.

Definition at line 145 of file Client.hpp.

virtual void samchon::templates::service::Client::sendData ( std::shared_ptr< protocol::Invoke invoke)
inlineoverridevirtual

Send an Invoke message.

Sends an Invoke message to remote client.

Parameters
invokeAn Invoke messgae to send to remote client.

Definition at line 164 of file Client.hpp.

Referenced by samchon::templates::service::User::sendData().

Here is the caller graph for this function:

virtual void samchon::templates::service::Client::replyData ( std::shared_ptr< protocol::Invoke invoke)
inlinevirtual

Handle a replied Invoke message.

The default Client.replyData() shifts chain to its parent User and belonged Service objects, by calling the the User.replyData() and Service.replyData() methods.

Note that, Client represents a remote client, not an user, a specific web page or service. Do not define logics about user or account information. It must be declared in the parent User class. Also, don't define processes of a specific a web page or service. Defines them in the child Service class.

1 class protocol.service.Client
2 {
3  public replyData(invoke: protocol.Invoke): void
4  {
5  // SHIFT TO PARENT USER
6  // THE PARENT USER ALSO MAY SHIFT TO ITS PARENT SERVER
7  this.getUser().replyData(invoke);
8 
9  // SHIFT TO BELOGED SERVICE
10  if (this.getService() != null)
11  this.getService().replyData(invoke);
12  }
13 }
14 
15 class MyClient extends protocol.service.Client
16 {
17  public replyData(invoke: protocol.Invoke): void
18  {
19  if (invoke.getListener() == "do_something_in_client_level")
20  this.do_something_in_client_level();
21  else
22  super.replyData(invoke);
23  }
24 }
Parameters
invokeAn invoke message to be handled in Client level.

Definition at line 209 of file Client.hpp.


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