TCPSession2 is gone. publish commands are gone but usable if you put them in your server.
This commit is contained in:
parent
a391882541
commit
e9cf447512
@ -9,14 +9,6 @@ namespace core {
|
||||
TCPServer::TCPServer(EPoll &ePoll, IPAddress address, std::string delimiter, int depth, std::string text)
|
||||
: TCPSocket(ePoll, text), commands(delimiter, depth) {
|
||||
|
||||
// commands.add(subscriptions, "publish"); // This needs to be removed and put into the servers that
|
||||
// commands.add(subscriptions, "unpublish"); // Others make. Plus it should be in a manager object that
|
||||
// commands.add(subscriptions, "subscribe"); // encapsulates all of the function.
|
||||
// commands.add(subscriptions, "unsubscribe");
|
||||
// commands.add(subscriptions, "catalog");
|
||||
// commands.add(subscriptions, "event");
|
||||
// commands.add(subscriptions, "invite");
|
||||
|
||||
setDescriptor(socket(AF_INET, SOCK_STREAM, 0));
|
||||
int yes = 1;
|
||||
setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
|
||||
|
@ -1,41 +0,0 @@
|
||||
#include "TCPSession2.h"
|
||||
#include "Exception.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
TCPSession2::TCPSession2(EPoll &ePoll, std::string text) : TCPSocket(ePoll, text) {}
|
||||
|
||||
TCPSession2::~TCPSession2() {}
|
||||
|
||||
void TCPSession2::output(std::stringstream &data) {
|
||||
data << "|" << ipAddress.getClientAddressAndPort();
|
||||
}
|
||||
|
||||
void TCPSession2::protocol(coreutils::ZString &data) {}
|
||||
|
||||
void TCPSession2::onRegistered() {
|
||||
onConnected();
|
||||
send();
|
||||
if(term)
|
||||
TCPSocket::shutdown("termination requested");
|
||||
}
|
||||
|
||||
void TCPSession2::onConnected() {}
|
||||
|
||||
|
||||
void TCPSession2::setBlockSize(int blockSize) {
|
||||
this->blockSize = blockSize;
|
||||
}
|
||||
|
||||
void TCPSession2::send() {
|
||||
if(out.tellp() > 0)
|
||||
TCPSocket::write(out.str());
|
||||
out.str("");
|
||||
}
|
||||
|
||||
void TCPSession2::terminate() {
|
||||
term = true;
|
||||
}
|
||||
|
||||
}
|
114
TCPSession2.h
114
TCPSession2.h
@ -1,114 +0,0 @@
|
||||
#ifndef __TCPSession2_h__
|
||||
# define __TCPSession2_h__
|
||||
|
||||
#include "TCPSocket.h"
|
||||
#include "Timer.h"
|
||||
#include "SessionFilter.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class Command;
|
||||
class TCPServer;
|
||||
|
||||
///
|
||||
/// TCPSession2
|
||||
///
|
||||
/// TCPSession defines the nature of the interaction with the client
|
||||
/// and stores persistent data for a defined session. TCPSession objects
|
||||
/// are not sockets but instead provide a communications control
|
||||
/// mechanism. Protocol conversations are provided through extensions
|
||||
/// from this object.
|
||||
///
|
||||
/// TCPSession2 is designed to be 'connected' instead of being served
|
||||
/// by a server.
|
||||
///
|
||||
|
||||
class TCPSession2 : public TCPSocket {
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
TCPSession2(EPoll &ePoll, std::string text = "");
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
virtual ~TCPSession2();
|
||||
|
||||
Command *grab = NULL;
|
||||
|
||||
virtual void output(std::stringstream &data);
|
||||
|
||||
///
|
||||
/// The send method is used to output the contents of the out stream
|
||||
/// to the session containing the stream.
|
||||
///
|
||||
|
||||
void send();
|
||||
|
||||
///
|
||||
/// Use this method to terminate this TCPSession.
|
||||
///
|
||||
|
||||
void terminate();
|
||||
|
||||
///
|
||||
/// Use out to send data to the session socket or other session sockets.
|
||||
///
|
||||
|
||||
std::stringstream out;
|
||||
|
||||
protected:
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
virtual void onRegistered() override;
|
||||
|
||||
///
|
||||
/// This method is called from within the protocol method when protocol is called
|
||||
/// on the initial connection where the data is an empty string. Use this method
|
||||
/// to deliver a message to the connection upon connection.
|
||||
///
|
||||
|
||||
virtual void onConnected();
|
||||
|
||||
///
|
||||
/// Override the protocol method to manage and control the session communications
|
||||
/// in your inherited session. If you do not override this method then the Session
|
||||
/// default will process the 'commands' added to the server object using the
|
||||
/// processRequest method on the session input.
|
||||
///
|
||||
/// When data is received within the session two modes are available to pass the
|
||||
/// data through the protocol method: LINE or BLOCK.
|
||||
///
|
||||
|
||||
virtual void protocol(coreutils::ZString &data);
|
||||
|
||||
///
|
||||
/// Use setBlockSize to set the amount of data that should be read at once from the
|
||||
/// session data buffer.
|
||||
/// If this value is set to 0 then the data will be retrieved
|
||||
///
|
||||
|
||||
void setBlockSize(int size = 0);
|
||||
|
||||
private:
|
||||
char *lineBuffer = NULL;
|
||||
int lineBufferSize = 0;
|
||||
int lineLength = 0;
|
||||
int blockLength = 0;
|
||||
std::mutex mtx;
|
||||
bool term = false;
|
||||
int blockSize = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user