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

#include <WebServerConnector.hpp>

Collaboration diagram for samchon::protocol::WebServerConnector:

Public Member Functions

virtual void connect (const std::string &ip, int port) override
 
virtual void connect (const std::string &ip, int port, const std::string &path)
 
- Public Member Functions inherited from samchon::protocol::ServerConnector
 ServerConnector (IProtocol *listener)
 
virtual ~ServerConnector ()=default
 
- Public Member Functions inherited from samchon::protocol::Communicator
virtual void close ()
 
virtual void replyData (std::shared_ptr< Invoke > invoke)
 
- Public Member Functions inherited from samchon::protocol::WebCommunicator
virtual void sendData (std::shared_ptr< Invoke > invoke) override
 

Detailed Description

A web-server connector.

The WebServerConnector is a type of WebCommunicator, specified for connecting to remote web-server who folows web-socket protocol and taking full charge of network communication with the remot web-server.

Create an WebServerConnector instance from a { listener} and call the connect() method. Then whenever a replied message comes from the remote system, the message will be converted to an Invoke object and the Invoke object will be shifted to the listener's IProtocol.replyData() method. Below code is an example connecting to remote server and interacting with it.

Note that, WebServerConnector connects to a remote web-server who follows the web-socket protocol. If the remote server is following not web-socket protocol, but protocol of Samchon Framework's own, then use ServerConnector instead.

Protocol Derived Type Connect to
Samchon Framework's own ServerConnector Server
Web-socket protocol WebServerConnector WebServer
Basic Components
See also
WebServer, IProtocol Protocol - Basic Components
Author
Jeongho Nam http://samchon.org

Definition at line 44 of file WebServerConnector.hpp.

Member Function Documentation

virtual void samchon::protocol::WebServerConnector::connect ( const std::string &  ip,
int  port 
)
inlineoverridevirtual

Connect to a web server.

Connects to a server with specified host address, port number and empty path. After the connection has succeeded, callback function onConnect is called. Listening data from the connected server also begins. Replied messages from the connected server will be converted to Invoke classes and will be shifted to the listener's replyData() method.

If the connection fails immediately, either an event is dispatched or an exception is thrown: an error event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, the status of the connection is reported by an event. If the socket is already connected, the existing connection is closed first.

Parameters
ipThe name or IP address of the host to connect to. If no host is specified, the host that is contacted is the host where the calling file resides. If you do not specify a host, use an event listener to determine whether the connection was successful.
portThe port number to connect to.

Reimplemented from samchon::protocol::ServerConnector.

Definition at line 81 of file WebServerConnector.hpp.

Referenced by samchon::templates::parallel::MediatorWebClient::start().

Here is the caller graph for this function:

virtual void samchon::protocol::WebServerConnector::connect ( const std::string &  ip,
int  port,
const std::string &  path 
)
inlinevirtual

Connect to a web server.

Connects to a server with specified host address, port number and path. After the connection has succeeded, callback function onConnect is called. Listening data from the connected server also begins. Replied messages from the connected server will be converted to Invoke classes and will be shifted to the listener's replyData() method.

If the connection fails immediately, either an event is dispatched or an exception is thrown: an error event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, the status of the connection is reported by an event. If the socket is already connected, the existing connection is closed first.

Parameters
ipThe name or IP address of the host to connect to. If no host is specified, the host that is contacted is the host where the calling file resides. If you do not specify a host, use an event listener to determine whether the connection was successful.
portThe port number to connect to.
pathPath of service which you want.

Definition at line 106 of file WebServerConnector.hpp.

References samchon::WeakString::between(), samchon::WeakString::str(), and samchon::library::StringUtil::substitute().

Here is the call graph for this function:


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