Create TCPSession2 for outpubound connections.
This commit is contained in:
1 parent
5c87225c6f
commit
fd70c79282
129 files changed
+1902
-710
No files matched your search
@@ -60,39 +60,39 @@ namespace core {
|
||||
|
||||
///
|
||||
/// setDescriptor establishes the file descriptor for the socket and registers the socket
|
||||
/// on the EPoll controller. setDescriptor will invoke the onRegister() event.
|
||||
/// on the EPoll controller. setDescriptor will invoke the onRegister() event.
|
||||
///
|
||||
|
||||
|
||||
void setDescriptor(int descriptor); ///<Set the descriptor for the socket.
|
||||
|
||||
int getDescriptor(); ///< Get the descriptor for the socket.
|
||||
|
||||
|
||||
int getDescriptor(); ///< Get the descriptor for the socket.
|
||||
|
||||
///
|
||||
/// The event received from epoll is sent through the eventReceived
|
||||
/// method which will parse the event and call the read and write
|
||||
/// callbacks on the socket.
|
||||
/// callbacks on the socket.
|
||||
///
|
||||
/// This method is called by the BMAEPoll object and should not be called
|
||||
/// from any user extended classes unless an epoll event is being
|
||||
/// simulated.
|
||||
///
|
||||
/// The return value of false will delete the socket object causing the destructors to run.
|
||||
/// The return value of true will enable the socket on ePoll to receive more events.
|
||||
/// The return value of false will delete the socket object causing the destructors to run.
|
||||
/// The return value of true will enable the socket on ePoll to receive more events.
|
||||
///
|
||||
|
||||
bool eventReceived(struct epoll_event event); ///< Parse epoll event and call specified callbacks.
|
||||
|
||||
bool eventReceived(struct epoll_event event, long long eventId); ///< Parse epoll event and call specified callbacks.
|
||||
|
||||
///
|
||||
/// Write data to the socket.
|
||||
///
|
||||
|
||||
|
||||
int write(std::string data);
|
||||
void write(char *buffer, int length);
|
||||
|
||||
void output(std::stringstream &out);
|
||||
|
||||
///
|
||||
/// The onRegister method is called before the socket is registered with
|
||||
/// The onRegister method is called before the socket is registered with
|
||||
/// ePoll so objects extending the Socket definition can initialize the socket
|
||||
/// before receiving events. Evoked when the
|
||||
/// descriptor is set using setDescriptor for the socket.
|
||||
@@ -100,11 +100,10 @@ namespace core {
|
||||
|
||||
virtual void onRegister(); ///< Called before the socket has registered with the epoll processing.
|
||||
virtual void onRegistered(); ///< Called after the socket has been registered with epoll processing.
|
||||
|
||||
|
||||
virtual void onUnregister();
|
||||
|
||||
|
||||
///
|
||||
/// The onUnregistered method is called whenever the socket is unregistered with
|
||||
/// ePoll and socket communcation events will be stopped. The default method will
|
||||
/// close the socket and clean up the connection. If this is overridden by an
|
||||
/// extended object then the object should call this method to clean the socket up.
|
||||
@@ -113,25 +112,25 @@ namespace core {
|
||||
virtual void onUnregistered(); ///< Called when the socket has finished unregistering for the epoll processing.
|
||||
|
||||
bool needsToWrite();
|
||||
|
||||
|
||||
bool reset = false;
|
||||
|
||||
volatile bool shutDown = false;
|
||||
|
||||
protected:
|
||||
|
||||
EPoll &ePoll; // The EPoll control object.
|
||||
|
||||
bool shutDown = false;
|
||||
|
||||
void setBufferSize(int length);
|
||||
|
||||
|
||||
int getBufferSize();
|
||||
|
||||
|
||||
///
|
||||
/// The onConnected method is called when the socket is ready to communicate.
|
||||
/// Writing to the socket can begin on this call to initiate a contact with the
|
||||
/// remote device.
|
||||
///
|
||||
|
||||
|
||||
// virtual void onConnected(); ///< Called when socket is open and ready to communicate.
|
||||
|
||||
///
|
||||
@@ -139,7 +138,7 @@ namespace core {
|
||||
///
|
||||
|
||||
// virtual void onDisconnected(); ///< Called when socket is closing and no longer ready to communicate.
|
||||
|
||||
|
||||
///
|
||||
/// The onDataReceived method is called when the socket has received an event from
|
||||
/// epoll and there is data ready to be read from the socket. The default handler
|
||||
@@ -147,39 +146,37 @@ namespace core {
|
||||
///
|
||||
/// @param data the data that has been received from the socket.
|
||||
///
|
||||
|
||||
|
||||
virtual void onDataReceived(std::string data); ///< Called when data is received from the socket.
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
virtual void onDataReceived(coreutils::ZString &data);
|
||||
|
||||
|
||||
virtual void onDataReceived(coreutils::ZString &data);
|
||||
|
||||
///
|
||||
/// receiveData will read the data from the socket and place it in the socket buffer.
|
||||
/// TLS layer overrides this to be able to read from SSL.
|
||||
///
|
||||
|
||||
virtual void receiveData(coreutils::ZString &buffer);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::string text;
|
||||
int descriptor = -1;
|
||||
// std::mutex lock;
|
||||
std::mutex outlock;
|
||||
bool readHangup = false;
|
||||
bool inHandler = false;
|
||||
// struct epoll_event event; // Event selection construction structure.
|
||||
volatile bool inHandler = false;
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// the writeSocket is called when epoll has received a write request for a socket.
|
||||
// the writeSocket is called when epoll has received a write request for a socket.
|
||||
// Writing data to this socket is queued in the streambuf and permission is requested
|
||||
// to write to the socket. This routine handles the writing of the streambuf data
|
||||
// buffer to the socket.
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
void writeSocket();
|
||||
|
||||
// int_type underflow();
|
||||
@@ -190,12 +187,8 @@ namespace core {
|
||||
char *buffer; // This is a pointer to the managed buffer space.
|
||||
int length; // This is the length of the buffer.
|
||||
|
||||
// const char * const begin_;
|
||||
// const char * const end_;
|
||||
// const char * const current_;
|
||||
|
||||
std::queue<std::string> fifo;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user