Commit f6fb4798 authored by legoc's avatar legoc
Browse files

Renamed RequestSocketImpl into RequestSocket

parent b071440a
......@@ -52,7 +52,7 @@ class SocketWaitingImpl;
class GenericWaitingImpl;
class WaitingImplSet;
class HandlerImpl;
class RequestSocketImpl;
class RequestSocket;
namespace application {
......@@ -110,8 +110,8 @@ public:
json::Object requestJSON(const std::string& request, int overrideTimeout = -1) const;
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint) const;
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint, int timeout) const;
std::unique_ptr<RequestSocket> createRequestSocket(const std::string& endpoint) const;
std::unique_ptr<RequestSocket> createRequestSocket(const std::string& endpoint, int timeout) const;
void removePort(const std::string& name) const;
......
......@@ -38,7 +38,7 @@ namespace application {
class EventListener;
class EventThread;
class ContextImpl;
class RequestSocketImpl;
class RequestSocket;
class Server {
......@@ -159,15 +159,15 @@ private:
void initStatus();
int getStreamPort(const std::string& name);
std::unique_ptr<OutputStreamSocket> createOutputStreamSocket(const std::string& name);
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint);
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint, int timeout);
std::unique_ptr<RequestSocket> createRequestSocket(const std::string& endpoint);
std::unique_ptr<RequestSocket> createRequestSocket(const std::string& endpoint, int timeout);
Endpoint m_serverEndpoint;
std::array<int, 3> m_serverVersion;
int m_statusPort;
std::unique_ptr<ContextImpl> m_contextImpl;
std::unique_ptr<RequestSocketImpl> m_requestSocket;
std::unique_ptr<RequestSocket> m_requestSocket;
std::mutex m_eventListenersMutex;
std::vector<EventListener *> m_eventListeners;
......
......@@ -26,7 +26,6 @@
#include "EventStreamSocket.h"
#include "impl/GenericWaitingImpl.h"
#include "impl/HandlerImpl.h"
#include "impl/RequestSocketImpl.h"
#include "impl/StreamSocketImpl.h"
#include "impl/WaitingImpl.h"
#include "impl/WaitingImplSet.h"
......@@ -34,6 +33,7 @@
#include "Strings.h"
#include "Server.h"
#include "Messages.h"
#include "RequestSocket.h"
#include <sstream>
#include <iostream>
#include <stdexcept>
......@@ -92,11 +92,11 @@ json::Object This::Com::requestJSON(const std::string& request, int overrideTime
return m_server->requestJSON(request, overrideTimeout);
}
std::unique_ptr<RequestSocketImpl> This::Com::createRequestSocket(const std::string& endpoint) const {
std::unique_ptr<RequestSocket> This::Com::createRequestSocket(const std::string& endpoint) const {
return m_server->createRequestSocket(endpoint);
}
std::unique_ptr<RequestSocketImpl> This::Com::createRequestSocket(const std::string& endpoint, int timeout) const {
std::unique_ptr<RequestSocket> This::Com::createRequestSocket(const std::string& endpoint, int timeout) const {
return m_server->createRequestSocket(endpoint, timeout);
}
......
......@@ -14,19 +14,19 @@
* limitations under the Licence.
*/
#include "RequestSocketImpl.h"
#include "RequestSocket.h"
#include "ConnectionTimeout.h"
#include "impl/ContextImpl.h"
#include <iostream>
#include <chrono>
#include <thread>
#include "ContextImpl.h"
using namespace std;
namespace cameo {
RequestSocketImpl::RequestSocketImpl(ContextImpl * context, const std::string& endpoint, int timeout) :
RequestSocket::RequestSocket(ContextImpl * context, const std::string& endpoint, int timeout) :
m_services(context), m_endpoint(endpoint) {
init();
......@@ -34,17 +34,17 @@ RequestSocketImpl::RequestSocketImpl(ContextImpl * context, const std::string& e
setTimeout(timeout);
}
RequestSocketImpl::~RequestSocketImpl() {
RequestSocket::~RequestSocket() {
}
void RequestSocketImpl::setTimeout(int timeout) {
void RequestSocket::setTimeout(int timeout) {
m_timeout = timeout;
// Apply the linger to the socket.
setSocketLinger();
}
void RequestSocketImpl::setSocketLinger() {
void RequestSocket::setSocketLinger() {
// Set the linger in case of timeout.
// If not, the context can block indefinitely.
// Does the value 100 can lead to a side-effect? A too small value like 1 has some side-effect.
......@@ -56,7 +56,7 @@ void RequestSocketImpl::setSocketLinger() {
}
}
void RequestSocketImpl::init() {
void RequestSocket::init() {
// Reset if the socket is null.
if (m_socket.get() == nullptr) {
......@@ -67,11 +67,11 @@ void RequestSocketImpl::init() {
}
}
void RequestSocketImpl::reset() {
void RequestSocket::reset() {
m_socket.reset();
}
std::unique_ptr<zmq::message_t> RequestSocketImpl::receive(int overrideTimeout) {
std::unique_ptr<zmq::message_t> RequestSocket::receive(int overrideTimeout) {
int timeout = m_timeout;
if (overrideTimeout > -1) {
......@@ -107,7 +107,7 @@ std::unique_ptr<zmq::message_t> RequestSocketImpl::receive(int overrideTimeout)
return reply;
}
std::string RequestSocketImpl::request(const std::string& request, int overrideTimeout) {
std::string RequestSocket::request(const std::string& request, int overrideTimeout) {
// Init if not already done or if a timeout occurred.
init();
......@@ -126,7 +126,7 @@ std::string RequestSocketImpl::request(const std::string& request, int overrideT
return std::string(response->data<char>(), response->size());
}
std::string RequestSocketImpl::request(const std::string& requestPart1, const std::string& requestPart2, int overrideTimeout) {
std::string RequestSocket::request(const std::string& requestPart1, const std::string& requestPart2, int overrideTimeout) {
// Init if not already done or if a timeout occurred.
init();
......@@ -149,7 +149,7 @@ std::string RequestSocketImpl::request(const std::string& requestPart1, const st
return std::string(response->data<char>(), response->size());
}
std::string RequestSocketImpl::request(const std::string& requestPart1, const std::string& requestPart2, const std::string& requestPart3, int overrideTimeout) {
std::string RequestSocket::request(const std::string& requestPart1, const std::string& requestPart2, const std::string& requestPart3, int overrideTimeout) {
// Init if not already done or if a timeout occurred.
init();
......@@ -176,7 +176,7 @@ std::string RequestSocketImpl::request(const std::string& requestPart1, const st
return std::string(response->data<char>(), response->size());
}
json::Object RequestSocketImpl::requestJSON(const std::string& request, int overrideTimeout) {
json::Object RequestSocket::requestJSON(const std::string& request, int overrideTimeout) {
std::string reply = this->request(request, overrideTimeout);
......@@ -187,7 +187,7 @@ json::Object RequestSocketImpl::requestJSON(const std::string& request, int over
return response;
}
json::Object RequestSocketImpl::requestJSON(const std::string& requestPart1, const std::string& requestPart2, int overrideTimeout) {
json::Object RequestSocket::requestJSON(const std::string& requestPart1, const std::string& requestPart2, int overrideTimeout) {
std::string reply = this->request(requestPart1, requestPart2, overrideTimeout);
......@@ -198,7 +198,7 @@ json::Object RequestSocketImpl::requestJSON(const std::string& requestPart1, con
return response;
}
json::Object RequestSocketImpl::requestJSON(const std::string& requestPart1, const std::string& requestPart2, const std::string& requestPart3, int overrideTimeout) {
json::Object RequestSocket::requestJSON(const std::string& requestPart1, const std::string& requestPart2, const std::string& requestPart3, int overrideTimeout) {
std::string reply = this->request(requestPart1, requestPart2, requestPart3, overrideTimeout);
......
......@@ -14,8 +14,8 @@
* limitations under the Licence.
*/
#ifndef CAMEO_REQUESTSOCKETIMPL_H_
#define CAMEO_REQUESTSOCKETIMPL_H_
#ifndef CAMEO_REQUESTSOCKET_H_
#define CAMEO_REQUESTSOCKET_H_
#include "JSON.h"
#include <string>
......@@ -26,11 +26,11 @@ namespace cameo {
class ContextImpl;
class RequestSocketImpl {
class RequestSocket {
public:
RequestSocketImpl(ContextImpl * context, const std::string& endpoint, int timeout = 0);
virtual ~RequestSocketImpl();
RequestSocket(ContextImpl * context, const std::string& endpoint, int timeout = 0);
virtual ~RequestSocket();
void setTimeout(int timeout);
void setSocketLinger();
......
......@@ -22,11 +22,11 @@
#include "UndefinedKeyException.h"
#include "EventThread.h"
#include "impl/CancelIdGenerator.h"
#include "impl/RequestSocketImpl.h"
#include "impl/StreamSocketImpl.h"
#include "impl/ContextImpl.h"
#include "JSON.h"
#include "Messages.h"
#include "RequestSocket.h"
#include <iostream>
#include <sstream>
#include <stdexcept>
......@@ -702,12 +702,12 @@ std::unique_ptr<OutputStreamSocket> Server::createOutputStreamSocket(const std::
return std::unique_ptr<OutputStreamSocket>(new OutputStreamSocket(new StreamSocketImpl(subscriber, cancelPublisher)));
}
std::unique_ptr<RequestSocketImpl> Server::createRequestSocket(const std::string& endpoint) {
return std::unique_ptr<RequestSocketImpl>(new RequestSocketImpl(m_contextImpl.get(), endpoint, m_contextImpl->getTimeout()));
std::unique_ptr<RequestSocket> Server::createRequestSocket(const std::string& endpoint) {
return std::unique_ptr<RequestSocket>(new RequestSocket(m_contextImpl.get(), endpoint, m_contextImpl->getTimeout()));
}
std::unique_ptr<RequestSocketImpl> Server::createRequestSocket(const std::string& endpoint, int timeout) {
return std::unique_ptr<RequestSocketImpl>(new RequestSocketImpl(m_contextImpl.get(), endpoint, timeout));
std::unique_ptr<RequestSocket> Server::createRequestSocket(const std::string& endpoint, int timeout) {
return std::unique_ptr<RequestSocket>(new RequestSocket(m_contextImpl.get(), endpoint, timeout));
}
std::ostream& operator<<(std::ostream& os, const cameo::Server& server) {
......
......@@ -17,13 +17,14 @@
#include "SocketException.h"
#include "ConnectionTimeout.h"
#include "JSON.h"
#include "RequestSocketImpl.h"
#include "../Messages.h"
#include <iostream>
#include <sstream>
#include "ContextImpl.h"
#include "../RequestSocket.h"
using namespace std;
namespace cameo {
......@@ -112,7 +113,7 @@ zmq::socket_t * ContextImpl::createRequestSocket(const std::string& endpoint) {
return socket;
}
bool ContextImpl::isAvailable(RequestSocketImpl * socket, int timeout) {
bool ContextImpl::isAvailable(RequestSocket * socket, int timeout) {
try {
socket->requestJSON(createSyncRequest(), timeout);
......@@ -128,7 +129,7 @@ bool ContextImpl::isAvailable(RequestSocketImpl * socket, int timeout) {
return false;
}
void ContextImpl::sendSyncStream(RequestSocketImpl * socket, const std::string& name) {
void ContextImpl::sendSyncStream(RequestSocket * socket, const std::string& name) {
try {
socket->requestJSON(createSyncStreamRequest(name));
......@@ -141,7 +142,7 @@ void ContextImpl::sendSyncStream(RequestSocketImpl * socket, const std::string&
}
}
void ContextImpl::waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket, const std::string& name) {
void ContextImpl::waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSocket * socket, const std::string& name) {
// Poll subscriber.
zmq_pollitem_t items[1];
......@@ -161,7 +162,7 @@ void ContextImpl::waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSoc
}
}
void ContextImpl::waitForSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket) {
void ContextImpl::waitForSubscriber(zmq::socket_t * subscriber, RequestSocket * socket) {
// Poll subscriber.
zmq_pollitem_t items[1];
......
......@@ -24,7 +24,7 @@
namespace cameo {
class RequestSocketImpl;
class RequestSocket;
class ContextImpl : public Context {
......@@ -40,10 +40,10 @@ public:
zmq::socket_t * createCancelPublisher(const std::string& endpoint);
zmq::socket_t * createRequestSocket(const std::string& endpoint);
bool isAvailable(RequestSocketImpl * socket, int timeout);
void sendSyncStream(RequestSocketImpl * socket, const std::string& name);
void waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket, const std::string& name);
void waitForSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket);
bool isAvailable(RequestSocket * socket, int timeout);
void sendSyncStream(RequestSocket * socket, const std::string& name);
void waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSocket * socket, const std::string& name);
void waitForSubscriber(zmq::socket_t * subscriber, RequestSocket * socket);
zmq::context_t m_context;
int m_timeout;
......
......@@ -17,8 +17,8 @@
#include "PublisherSubscriber.h"
#include "../base/impl/ContextImpl.h"
#include "../base/impl/RequestSocketImpl.h"
#include "../base/Messages.h"
#include "../base/RequestSocket.h"
#include "impl/PublisherImpl.h"
#include "impl/SubscriberImpl.h"
#include "JSON.h"
......
......@@ -17,8 +17,8 @@
#include "RequesterResponder.h"
#include "../base/impl/ContextImpl.h"
#include "../base/impl/RequestSocketImpl.h"
#include "../base/Messages.h"
#include "../base/RequestSocket.h"
#include "impl/RequesterImpl.h"
#include "impl/RequestImpl.h"
#include "impl/ResponderImpl.h"
......
......@@ -19,9 +19,9 @@
#include "Application.h"
#include "Serializer.h"
#include "JSON.h"
#include "../../base/impl/RequestSocketImpl.h"
#include "../../base/impl/ContextImpl.h"
#include "../../base/Messages.h"
#include "../../base/RequestSocket.h"
#include <sstream>
namespace cameo {
......@@ -127,7 +127,7 @@ void PublisherImpl::cancelWaitForSubscribers() {
request.pushInt(message::CANCEL);
// Create a request socket only for the request.
std::unique_ptr<RequestSocketImpl> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_synchronizerPort).toString());
std::unique_ptr<RequestSocket> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_synchronizerPort).toString());
requestSocket->requestJSON(request.toString());
}
......
......@@ -19,9 +19,9 @@
#include "Application.h"
#include "Serializer.h"
#include "JSON.h"
#include "../../base/impl/RequestSocketImpl.h"
#include "../../base/impl/ContextImpl.h"
#include "../../base/Messages.h"
#include "../../base/RequestSocket.h"
#include <sstream>
namespace cameo {
......@@ -56,7 +56,7 @@ bool RequestImpl::replyBinary(const std::string& response) {
request.pushInt(message::RESPONSE);
// Create a request socket. It is created for each request that could be optimized.
std::unique_ptr<RequestSocketImpl> requestSocket = application::This::getCom().createRequestSocket(m_requesterEndpoint);
std::unique_ptr<RequestSocket> requestSocket = application::This::getCom().createRequestSocket(m_requesterEndpoint);
try {
requestSocket->request(request.toString(), response);
......
......@@ -19,9 +19,9 @@
#include "Application.h"
#include "Serializer.h"
#include "JSON.h"
#include "../../base/impl/RequestSocketImpl.h"
#include "../../base/impl/ContextImpl.h"
#include "../../base/Messages.h"
#include "../../base/RequestSocket.h"
#include <sstream>
namespace cameo {
......@@ -181,7 +181,7 @@ void RequesterImpl::cancel() {
request.pushInt(message::CANCEL);
// Create a request socket only for the request.
std::unique_ptr<RequestSocketImpl> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_requesterPort).toString());
std::unique_ptr<RequestSocket> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_requesterPort).toString());
requestSocket->requestJSON(request.toString());
}
......
......@@ -28,7 +28,7 @@
namespace cameo {
class RequestSocketImpl;
class RequestSocket;
namespace coms {
......@@ -57,7 +57,7 @@ public:
std::string m_name;
int m_responderId;
int m_requesterId;
std::unique_ptr<RequestSocketImpl> m_requestSocket;
std::unique_ptr<RequestSocket> m_requestSocket;
std::unique_ptr<zmq::socket_t> m_repSocket;
bool m_canceled;
......
......@@ -20,9 +20,9 @@
#include "Application.h"
#include "Serializer.h"
#include "JSON.h"
#include "../../base/impl/RequestSocketImpl.h"
#include "../../base/impl/ContextImpl.h"
#include "../../base/Messages.h"
#include "../../base/RequestSocket.h"
#include <sstream>
namespace cameo {
......@@ -55,7 +55,7 @@ void ResponderImpl::cancel() {
request.pushInt(message::CANCEL);
// Create a request socket.
std::unique_ptr<RequestSocketImpl> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_responderPort).toString());
std::unique_ptr<RequestSocket> requestSocket = application::This::getCom().createRequestSocket(application::This::getEndpoint().withPort(m_responderPort).toString());
requestSocket->requestJSON(request.toString());
}
......
......@@ -20,9 +20,9 @@
#include "Server.h"
#include "JSON.h"
#include "../../base/impl/CancelIdGenerator.h"
#include "../../base/impl/RequestSocketImpl.h"
#include "../../base/impl/ContextImpl.h"
#include "../../base/Messages.h"
#include "../../base/RequestSocket.h"
#include <sstream>
namespace cameo {
......@@ -74,7 +74,7 @@ void SubscriberImpl::init() {
if (m_numberOfSubscribers > 0) {
// Create a request socket.
std::unique_ptr<RequestSocketImpl> requestSocket = application::This::getCom().createRequestSocket(m_serverEndpoint.withPort(m_synchronizerPort).toString());
std::unique_ptr<RequestSocket> requestSocket = application::This::getCom().createRequestSocket(m_serverEndpoint.withPort(m_synchronizerPort).toString());
// Poll subscriber.
zmq_pollitem_t items[1];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment