From 9b9e12d03c2125b5c9a929eeece84bc638ed9636 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Wed, 8 Mar 2023 13:56:52 -0800 Subject: [PATCH] session --- Socket.cpp | 10 +-- Socket.h | 2 +- TCPServer.h | 2 +- TCPSession.cpp | 4 + html/Socket_8h_source.html | 2 +- html/TCPServer_8h_source.html | 2 +- html/TCPSession_8h_source.html | 72 +++++++-------- html/classcore_1_1ConsoleServer-members.html | 83 +++++++++-------- html/classcore_1_1ConsoleServer.html | 3 - html/classcore_1_1ConsoleSession-members.html | 65 +++++++------- html/classcore_1_1ConsoleSession.html | 3 + html/classcore_1_1TCPServer-members.html | 79 ++++++++-------- html/classcore_1_1TCPServer.html | 3 - html/classcore_1_1TCPSession-members.html | 43 ++++----- html/classcore_1_1TCPSession.html | 3 + html/classcore_1_1TCPSocket-members.html | 4 +- html/classcore_1_1TLSServer-members.html | 89 +++++++++---------- html/classcore_1_1TLSServer.html | 3 - html/classcore_1_1TLSSession-members.html | 45 +++++----- html/classcore_1_1TLSSession.html | 3 + .../classcore_1_1TerminalSession-members.html | 61 ++++++------- html/classcore_1_1TerminalSession.html | 3 + latex/classcore_1_1TCPServer.tex | 3 - latex/classcore_1_1TCPSession.tex | 3 + 24 files changed, 300 insertions(+), 290 deletions(-) diff --git a/Socket.cpp b/Socket.cpp index f3e724d..0168536 100644 --- a/Socket.cpp +++ b/Socket.cpp @@ -68,7 +68,7 @@ namespace core void Socket::onUnregistered() {} bool Socket::eventReceived(struct epoll_event event, long long eventId) { - lock.lock(); +// lock.lock(); inHandler = true; if(event.events & EPOLLRDHUP) { readHangup = true; @@ -85,7 +85,7 @@ namespace core shutdown(); } inHandler = false; - lock.unlock(); +// lock.unlock(); return !shutDown; } @@ -149,9 +149,9 @@ namespace core fifo.emplace(data); outlock.unlock(); if(sender && (sender != this)) - lock.lock(); - ePoll.resetSocket(this); - lock.unlock(); + if(!inHandler) { + ePoll.resetSocket(this); + } return 1; } diff --git a/Socket.h b/Socket.h index 8d36251..9f988df 100644 --- a/Socket.h +++ b/Socket.h @@ -167,7 +167,7 @@ namespace core { std::string text; int descriptor = -1; std::mutex outlock; - std::mutex lock; +// std::mutex lock; bool readHangup = false; volatile bool inHandler = false; diff --git a/TCPServer.h b/TCPServer.h index 1feb96c..2a85e10 100644 --- a/TCPServer.h +++ b/TCPServer.h @@ -46,7 +46,7 @@ namespace core virtual ~TCPServer(); virtual void sessionErrorHandler(std::string errorString, std::stringstream &out); - virtual bool compareAlias(void *alias, void *compare); + /// /// getSocketAccept is designed to allow a polymorphic extension of this object to /// return a type of object that extends the definition of the server socket. diff --git a/TCPSession.cpp b/TCPSession.cpp index 5f4efb5..f1a3c5b 100644 --- a/TCPSession.cpp +++ b/TCPSession.cpp @@ -42,6 +42,10 @@ namespace core return this->alias = alias; } + void TCPSession::outputAlias(std::stringstream &out) { + out << alias; + } + void TCPSession::onRegistered() { onConnected(); diff --git a/html/Socket_8h_source.html b/html/Socket_8h_source.html index 84d33e5..63d37de 100644 --- a/html/Socket_8h_source.html +++ b/html/Socket_8h_source.html @@ -147,7 +147,7 @@ $(function() {
167  std::string text;
168  int descriptor = -1;
169  std::mutex outlock;
-
170  std::mutex lock;
+
170 // std::mutex lock;
171  bool readHangup = false;
172  volatile bool inHandler = false;
173 
diff --git a/html/TCPServer_8h_source.html b/html/TCPServer_8h_source.html index d8ab9e1..1bf1758 100644 --- a/html/TCPServer_8h_source.html +++ b/html/TCPServer_8h_source.html @@ -91,7 +91,7 @@ $(function() {
46  virtual ~TCPServer();
47 
48  virtual void sessionErrorHandler(std::string errorString, std::stringstream &out);
-
49  virtual bool compareAlias(void *alias, void *compare);
+
49 
57 
58  virtual TCPSession *getSocketAccept(EPoll &epoll);
59 
diff --git a/html/TCPSession_8h_source.html b/html/TCPSession_8h_source.html index a58f465..86ccc2d 100644 --- a/html/TCPSession_8h_source.html +++ b/html/TCPSession_8h_source.html @@ -113,57 +113,59 @@ $(function() {
89 
90  virtual bool compareAlias(void *alias);
91 
-
92  protected:
-
96 
-
97  virtual void onRegistered() override;
+
92  virtual void outputAlias(std::stringstream &out);
+
93 
+
94  protected:
98 
-
104  virtual void onDataReceived(coreutils::ZString &data) override;
-
105 
-
112 
-
113  virtual void onLineReceived(coreutils::ZString &line);
+
99  virtual void onRegistered() override;
+
100 
+
106  virtual void onDataReceived(coreutils::ZString &data) override;
+
107 
114 
-
121 
-
122  virtual void onBlockReceived(coreutils::ZString &block);
+
115  virtual void onLineReceived(coreutils::ZString &line);
+
116 
123 
-
129 
-
130  virtual void onConnected();
+
124  virtual void onBlockReceived(coreutils::ZString &block);
+
125 
131 
-
141 
-
142  virtual void protocol(coreutils::ZString &data);
+
132  virtual void onConnected();
+
133 
143 
-
149 
-
150  void setBlockSize(int size = 0);
+
144  virtual void protocol(coreutils::ZString &data);
+
145 
151 
-
152  private:
-
153  char *lineBuffer = NULL;
-
154  int lineBufferSize = 0;
-
155  int lineLength = 0;
-
156  int blockLength = 0;
-
157  std::mutex mtx;
-
158  bool term = false;
-
159  int blockSize = 0;
-
160  };
-
161 
-
162 }
+
152  void setBlockSize(int size = 0);
+
153 
+
154  private:
+
155  char *lineBuffer = NULL;
+
156  int lineBufferSize = 0;
+
157  int lineLength = 0;
+
158  int blockLength = 0;
+
159  std::mutex mtx;
+
160  bool term = false;
+
161  int blockSize = 0;
+
162  };
163 
-
164 #endif
+
164 }
+
165 
+
166 #endif
Definition: Command.h:22
Definition: EPoll.h:31
Definition: TCPServer.h:28
Definition: TCPSession.h:26
void * alias
Definition: TCPSession.h:84
-
void send()
Definition: TCPSession.cpp:115
+
void send()
Definition: TCPSession.cpp:119
char uuid[37]
Definition: TCPSession.h:76
-
void terminate()
Definition: TCPSession.cpp:121
-
virtual void onLineReceived(coreutils::ZString &line)
Definition: TCPSession.cpp:100
+
void terminate()
Definition: TCPSession.cpp:125
+
virtual void onLineReceived(coreutils::ZString &line)
Definition: TCPSession.cpp:104
virtual void output(std::stringstream &data)
Definition: TCPSession.cpp:25
-
void setBlockSize(int size=0)
Definition: TCPSession.cpp:95
-
virtual void onConnected()
Definition: TCPSession.cpp:55
+
void setBlockSize(int size=0)
Definition: TCPSession.cpp:99
+
virtual void onConnected()
Definition: TCPSession.cpp:59
virtual void protocol(coreutils::ZString &data)
Definition: TCPSession.cpp:30
-
virtual void onBlockReceived(coreutils::ZString &block)
Definition: TCPSession.cpp:108
+
virtual void onBlockReceived(coreutils::ZString &block)
Definition: TCPSession.cpp:112
std::stringstream out
Definition: TCPSession.h:68
-
virtual void onRegistered() override
Called after the socket has been registered with epoll processing.
Definition: TCPSession.cpp:45
-
virtual void onDataReceived(coreutils::ZString &data) override
Definition: TCPSession.cpp:57
+
virtual void onRegistered() override
Called after the socket has been registered with epoll processing.
Definition: TCPSession.cpp:49
+
virtual void onDataReceived(coreutils::ZString &data) override
Definition: TCPSession.cpp:61
Definition: TCPSocket.h:20
diff --git a/html/classcore_1_1ConsoleServer-members.html b/html/classcore_1_1ConsoleServer-members.html index d658ee0..2807248 100644 --- a/html/classcore_1_1ConsoleServer-members.html +++ b/html/classcore_1_1ConsoleServer-members.html @@ -74,49 +74,48 @@ $(function() { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + +
blackListcore::TCPServer
commandscore::TCPServer
compareAlias(void *alias, void *compare) (defined in core::TCPServer)core::TCPServervirtual
connect(IPAddress &address) (defined in core::TCPSocket)core::TCPSocket
ConsoleServer(EPoll &ePoll, IPAddress address) (defined in core::ConsoleServer)core::ConsoleServer
ePoll (defined in core::Socket)core::Socketprotected
eventReceived(struct epoll_event event, long long eventId)core::Socket
getBufferSize() (defined in core::Socket)core::Socketprotected
getDescriptor()core::Socket
getSessionByAlias(void *alias)core::TCPServer
getSocketAccept(EPoll &ePoll) overridecore::ConsoleServervirtual
ipAddress (defined in core::TCPSocket)core::TCPSocket
logSend(std::string out) override (defined in core::ConsoleServer)core::ConsoleServer
needsToWrite() (defined in core::Socket)core::Socket
onDataReceived(std::string data) overridecore::TCPServerprotectedvirtual
onDataReceived(coreutils::ZString &data) (defined in core::Socket)core::Socketprotectedvirtual
onRegister()core::Socketvirtual
onRegistered()core::Socketvirtual
onUnregister() (defined in core::Socket)core::Socketvirtual
onUnregistered()core::Socketvirtual
output(std::stringstream &out)core::TCPServervirtual
processCommand(coreutils::ZString &request, TCPSession &session) overridecore::TCPServerprotectedvirtual
receiveData(coreutils::ZString &buffer)core::Socketprotectedvirtual
removeFromSessionList(TCPSession *session) (defined in core::TCPServer)core::TCPServer
reset (defined in core::Socket)core::Socket
sendToAll(std::stringstream &out) (defined in core::TCPServer)core::TCPServer
sendToAll(std::stringstream &out, TCPSession &sender, SessionFilter filter)core::TCPServer
sendToAll(std::stringstream &out, TCPSession &sender)core::TCPServer
sessionErrorHandler(std::string errorString, std::stringstream &out) (defined in core::TCPServer)core::TCPServervirtual
sessionscore::TCPServer
setBufferSize(int length) (defined in core::Socket)core::Socketprotected
setDescriptor(int descriptor)core::Socket
shutDown (defined in core::Socket)core::Socket
connect(IPAddress &address) (defined in core::TCPSocket)core::TCPSocket
ConsoleServer(EPoll &ePoll, IPAddress address) (defined in core::ConsoleServer)core::ConsoleServer
ePoll (defined in core::Socket)core::Socketprotected
eventReceived(struct epoll_event event, long long eventId)core::Socket
getBufferSize() (defined in core::Socket)core::Socketprotected
getDescriptor()core::Socket
getSessionByAlias(void *alias)core::TCPServer
getSocketAccept(EPoll &ePoll) overridecore::ConsoleServervirtual
ipAddress (defined in core::TCPSocket)core::TCPSocket
logSend(std::string out) override (defined in core::ConsoleServer)core::ConsoleServer
needsToWrite() (defined in core::Socket)core::Socket
onDataReceived(std::string data) overridecore::TCPServerprotectedvirtual
onDataReceived(coreutils::ZString &data) (defined in core::Socket)core::Socketprotectedvirtual
onRegister()core::Socketvirtual
onRegistered()core::Socketvirtual
onUnregister() (defined in core::Socket)core::Socketvirtual
onUnregistered()core::Socketvirtual
output(std::stringstream &out)core::TCPServervirtual
processCommand(coreutils::ZString &request, TCPSession &session) overridecore::TCPServerprotectedvirtual
receiveData(coreutils::ZString &buffer)core::Socketprotectedvirtual
removeFromSessionList(TCPSession *session) (defined in core::TCPServer)core::TCPServer
reset (defined in core::Socket)core::Socket
sendToAll(std::stringstream &out) (defined in core::TCPServer)core::TCPServer
sendToAll(std::stringstream &out, TCPSession &sender, SessionFilter filter)core::TCPServer
sendToAll(std::stringstream &out, TCPSession &sender)core::TCPServer
sessionErrorHandler(std::string errorString, std::stringstream &out) (defined in core::TCPServer)core::TCPServervirtual
sessionscore::TCPServer
setBufferSize(int length) (defined in core::Socket)core::Socketprotected
setDescriptor(int descriptor)core::Socket
shutdown(std::string text="unknown")core::Socket
Socket(EPoll &ePoll, std::string text="")core::Socket
subscriptionscore::TCPServer
TCPServer(EPoll &ePoll, IPAddress address, std::string delimiter=" ", int depth=10, std::string text="")core::TCPServer
TCPSocket(EPoll &ePoll) (defined in core::TCPSocket)core::TCPSocket
TCPSocket(EPoll &ePoll, std::string text) (defined in core::TCPSocket)core::TCPSocket
whiteListcore::TCPServer
write(std::string data, Socket *sender=NULL)core::Socket
write(char *buffer, int length) (defined in core::Socket)core::Socket
~Socket()core::Socketvirtual
~TCPServer()core::TCPServervirtual
~TCPSocket() (defined in core::TCPSocket)core::TCPSocketvirtual
shutDown (defined in core::Socket)core::Socket
Socket(EPoll &ePoll, std::string text="")core::Socket
subscriptionscore::TCPServer
TCPServer(EPoll &ePoll, IPAddress address, std::string delimiter=" ", int depth=10, std::string text="")core::TCPServer
TCPSocket(EPoll &ePoll) (defined in core::TCPSocket)core::TCPSocket
TCPSocket(EPoll &ePoll, std::string text) (defined in core::TCPSocket)core::TCPSocket
whiteListcore::TCPServer
write(std::string data, Socket *sender=NULL)core::Socket
write(char *buffer, int length) (defined in core::Socket)core::Socket
~Socket()core::Socketvirtual
~TCPServer()core::TCPServervirtual
~TCPSocket() (defined in core::TCPSocket)core::TCPSocketvirtual