Samchon Framework for CPP  1.0.0
samchon::protocol::IClient Class Reference

An interface for a client. More...

#include <IClient.hpp>

Collaboration diagram for samchon::protocol::IClient:

Public Member Functions

 IClient ()
 Default Constructor. More...
 
virtual void listen ()
 Listens message from a related system. More...
 
virtual void sendData (std::shared_ptr< Invoke >)
 Sends message to a related system. More...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
 IProtocol ()
 Default Constructor. More...
 
virtual void replyData (std::shared_ptr< Invoke >)
 Reply a message. More...
 

Protected Member Functions

virtual auto BUFFER_SIZE () const -> size_t
 Buffer size of network I/O. More...
 
virtual void _replyData (std::shared_ptr< Invoke >)
 A method for pre-processing replied Invoke message. More...
 

Protected Attributes

Socket * socket
 Socket for network I/O. More...
 
std::mutex * sendMtx
 A mutex for sending message. More...
 

Detailed Description

An interface for a client.

IClient is an interface not only for a physical client, but also a driver for a client in a physical server.

IClient is one of the basic 3 + 1 components that can make any type of network system in Samchon Framework with IProtocol and IServer. Looking around classes in Samchon Framework, you can see all classes related with client are implemented from the IClient.

IClient takes a role of real network I/O. IClient sends data to otherside network system from IProtocol::sendData(). IClient also gets data from otherside network system, generates standard Invoke message from parsing the replied data and shift the Invoke message to IProtocol::replyData().

protocol_interface.png
Author
Jeongho Nam http://samchon.org

Definition at line 53 of file IClient.hpp.

Constructor & Destructor Documentation

IClient::IClient ( )

Default Constructor.

Definition at line 30 of file IClient.cpp.

Member Function Documentation

auto IClient::BUFFER_SIZE ( ) const -> size_t
protectedvirtual

Buffer size of network I/O.

Definition at line 25 of file IClient.cpp.

Referenced by samchon::protocol::IWebClientBase::listen().

Here is the caller graph for this function:

void IClient::listen ( )
virtual

Listens message from a related system.

Note
It holds (monopolies) a thread.

Reimplemented in samchon::protocol::IWebClientBase.

Definition at line 45 of file IClient.cpp.

References samchon::WeakString::betweens(), samchon::ByteArray::getPosition(), samchon::ByteArray::read(), and samchon::ByteArray::setPosition().

Referenced by samchon::example::console_chat_server::ChatServer::addClient(), samchon::protocol::ExternalClient::start(), and samchon::protocol::ExternalServer::start().

Here is the call graph for this function:

Here is the caller graph for this function:

void IClient::_replyData ( std::shared_ptr< Invoke )
protectedvirtual

A method for pre-processing replied Invoke message.

You can realize a pre-processing about the replied Invoke message by overriding the IClient::_replyData().

Archiving a history log, filtering and truncating, let handling the message with a new thread, calculating performance by estimating elapsed time about the Invoke message, and so on. Anything you can define pre-processing works before IProtocol::replyData().

  • Archive history log -> cloud service
  • Estimating performance -> distributed and parallel processing system
Parameters
invokeAn invoke message to be pre-processed and shifted to IProtocol::replyData().

Reimplemented in samchon::protocol::master::ParallelSystem, samchon::protocol::slave::SlaveSystem, and samchon::protocol::slave::ParallelSystem.

Definition at line 333 of file IClient.cpp.

Referenced by samchon::protocol::IWebClientBase::listen().

Here is the caller graph for this function:

Member Data Documentation

std::mutex* samchon::protocol::IClient::sendMtx
protected

A mutex for sending message.

Definition at line 65 of file IClient.hpp.

Referenced by samchon::protocol::IWebClientBase::sendData(), and samchon::protocol::service::Client::sendData().


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