Samchon Framework for CPP  1.0.0
samchon::protocol::service::IPUserPair Class Reference

Relationship between IP address and User for issuing session. More...

#include <IPUserPair.hpp>

Collaboration diagram for samchon::protocol::service::IPUserPair:

Private Member Functions

 IPUserPair (Server *server, const std::string &)
 Construct from Server and IP address. More...
 
auto getSessionID (Socket *, size_t) -> std::string
 Get a session ID. More...
 
auto issueSessionID (size_t) const -> std::string
 Issue a session ID. More...
 

Private Attributes

Serverserver
 The Server containing IP addresses and User(s) More...
 
std::string ip
 An IP address. More...
 
std::set< const User * > userSet
 User(s) belongs to the IP address. More...
 

Detailed Description

Relationship between IP address and User for issuing session.

IPUserPair is a class representing 1:N relationship between IP address and User.

The key role of IPUserPair is to issuing session ID, that is published to User(s), within a critical section of an IP address.

protocol_service.png
Note

Samchon Framework is for Cloud Server basically, so I've adopted Session ID to discriminate unique User to follow standard. But I think there can be another good strategies something like a using MAC address instead of publishing Session-ID to discriminate uniqueness of User. It's okay to adapt those strategies and rebuild my framework's source to be suitable for those.

Warning

When changing the strategy, you've to careful about policy of each system or libraries.

Followings are something to consider when adjusting MAC address for uniqueness.

  • In server side and view of socket, boost::asio or candidate network i/o libary of stl does not allow accessing otherside system's MAC address. But basic socket of window or linux are allowed.
  • In client side and view of browser, IE allows to get MAC address by javascript with ActiveX, but other browsers do not allow.
See also
samchon::protocol
samchon::protocol::service
Author
Jeongho Nam http://samchon.org

Definition at line 51 of file IPUserPair.hpp.

Constructor & Destructor Documentation

IPUserPair::IPUserPair ( Server server,
const std::string &   
)
private

Construct from Server and IP address.

Definition at line 25 of file IPUserPair.cpp.

Member Function Documentation

auto IPUserPair::getSessionID ( Socket *  socket,
size_t  sequence 
) -> std::string
private

Get a session ID.

Asks Whether client to have a session id stored in cookie.

If client has, get the session id from client, but if not, issues a new session ID and notify it(enrolled new session ID) to client. Additionally, if the session id was gotten from a client, inspect validate of the session ID.

Those tasks will hold a critical section of a global IP address

Warning
The session id must be unique
Returns
A new session ID that can ensure uniqueness

Definition at line 30 of file IPUserPair.cpp.

auto IPUserPair::issueSessionID ( size_t  sequence) const -> std::string
private

Issue a session ID.

Issues a session ID when a target client haven't issued seesion ID yet

Default organization of the Session ID
  • {$name}::{$port}::{$sequence}::{$linux_time}
    1. $name: Name of the Server; Server::NAME()
    2. $port: Port number of the Server; Server::PORT()
    3. $sequence: Sequence number of creation of User in Server
    4. $linux_time: Linux time of current time.

      If the object Server is re-constructed, $sequence can be duplicated. $linux_time is to avoid the duplication so that can ensure uniqueness on session id

Definition at line 81 of file IPUserPair.cpp.

References samchon::library::Date::toLinuxTime().

Here is the call graph for this function:

Member Data Documentation

Server* samchon::protocol::service::IPUserPair::server
private

The Server containing IP addresses and User(s)

Definition at line 60 of file IPUserPair.hpp.

std::string samchon::protocol::service::IPUserPair::ip
private

An IP address.

Definition at line 65 of file IPUserPair.hpp.

Referenced by samchon::protocol::service::Server::addClient().

std::set<const User*> samchon::protocol::service::IPUserPair::userSet
private

User(s) belongs to the IP address.

Definition at line 70 of file IPUserPair.hpp.

Referenced by samchon::protocol::service::Server::addClient().


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