From 63943e02ddafdb5b144220d5a5ac73e744777bca Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Mon, 4 May 2020 10:04:24 -0700 Subject: [PATCH] Continued development on Command and CommandList. --- Command.cpp | 12 +++ Command.h | 10 ++- html/EPoll_8h_source.html | 32 ++++---- html/Socket_8h_source.html | 12 +-- html/TCPSession_8h_source.html | 71 +++++++++--------- html/classcore_1_1ConsoleServer-members.html | 60 +++++++-------- html/classcore_1_1ConsoleServer.html | 12 +-- html/classcore_1_1ConsoleSession-members.html | 73 ++++++++++--------- html/classcore_1_1ConsoleSession.html | 15 ++-- html/classcore_1_1EPoll-members.html | 2 +- html/classcore_1_1EPoll.html | 28 ++----- html/classcore_1_1Socket-members.html | 30 ++++---- html/classcore_1_1Socket.html | 28 +++---- html/classcore_1_1TCPServer-members.html | 52 ++++++------- html/classcore_1_1TCPServer.html | 12 +-- html/classcore_1_1TCPSession-members.html | 59 +++++++-------- html/classcore_1_1TCPSession.html | 15 ++-- html/classcore_1_1TCPSocket-members.html | 34 ++++----- html/classcore_1_1TCPSocket.html | 12 +-- html/classcore_1_1TLSServer-members.html | 60 +++++++-------- html/classcore_1_1TLSServer.html | 12 +-- html/classcore_1_1TLSSession-members.html | 63 ++++++++-------- html/classcore_1_1TLSSession.html | 15 ++-- .../classcore_1_1TerminalSession-members.html | 71 +++++++++--------- html/classcore_1_1TerminalSession.html | 15 ++-- .../classcore_1_1UDPServerSocket-members.html | 44 +++++------ html/classcore_1_1UDPServerSocket.html | 12 +-- html/classcore_1_1UDPSocket-members.html | 30 ++++---- html/classcore_1_1UDPSocket.html | 12 +-- html/functions.html | 4 +- html/functions_func.html | 4 +- html/search/all_3.js | 2 +- html/search/functions_2.js | 2 +- latex/classcore_1_1EPoll.tex | 11 +-- latex/classcore_1_1Socket.tex | 10 +-- latex/classcore_1_1TCPSession.tex | 3 + 36 files changed, 475 insertions(+), 464 deletions(-) diff --git a/Command.cpp b/Command.cpp index 549da7e..6720121 100644 --- a/Command.cpp +++ b/Command.cpp @@ -2,10 +2,22 @@ #include "Log.h" namespace core { + + Command::Command() {} + Command::Command(CommandList &commandList) : commandList(commandList) {} + int Command::processCommand(std::string request, TCPSession *session, std::stringstream &data) { return 0; } + + void grabInput() { + commandList.grapInput(this); + } + + void clearGrab() { + commandList.clearGrab(this); + } void Command::output(Session *session) {} diff --git a/Command.h b/Command.h index 7a34837..31c66c0 100644 --- a/Command.h +++ b/Command.h @@ -20,6 +20,9 @@ namespace core { class Command : public Object { public: + + Command(); + Command(CommandList &commandList); /// /// Implement check method to provide a special check rule upon the request to see @@ -70,9 +73,14 @@ namespace core { void setName(std::string name); std::string getName(); - + + void grabInput(); + void clearGrab(); + private: std::string name; + CommandList &commandList; + }; diff --git a/html/EPoll_8h_source.html b/html/EPoll_8h_source.html index 85e177b..38a42cf 100644 --- a/html/EPoll_8h_source.html +++ b/html/EPoll_8h_source.html @@ -109,7 +109,7 @@ $(function() {
98  int maxSockets;
99 
103 
-
104  void eventReceived(struct epoll_event event, pid_t threadId);
+
104  void eventReceived(struct epoll_event event);
105 
112 
113  int processCommand(std::string command, TCPSession *session, std::stringstream &data) override;
@@ -120,32 +120,30 @@ $(function() {
118 
119  int epfd;
120  int numberOfThreads;
-
121  std::map<int, Socket *> sockets;
-
122  std::vector<Thread> threads;
-
123  volatile bool terminateThreads;
-
124  std::mutex lock;
-
125  void enableSocket(Socket *socket);
-
126  void disableSocket(Socket *socket);
-
127 
-
128  };
-
129 
-
130 }
+
121  std::vector<Thread> threads;
+
122  volatile bool terminateThreads;
+
123  void enableSocket(Socket *socket);
+
124  void disableSocket(Socket *socket);
+
125 
+
126  };
+
127 
+
128 }
+
129 
+
130 #endif
131 
-
132 #endif
-
133 
bool isStopping()
Returns a true if the stop command has been requested.
Definition: EPoll.cpp:67
bool start(int numberOfThreads, int maxSockets)
Start the BMAEPoll processing.
Definition: EPoll.cpp:21
Definition: TCPSession.h:23
Definition: Socket.h:33
-
bool unregisterSocket(Socket *socket)
Unregister a BMASocket from monitoring by BMAEPoll.
Definition: EPoll.cpp:83
+
bool unregisterSocket(Socket *socket)
Unregister a BMASocket from monitoring by BMAEPoll.
Definition: EPoll.cpp:77
Definition: EPoll.h:31
bool stop()
Stop and shut down the BMAEPoll processing.
Definition: EPoll.cpp:47
-
void eventReceived(struct epoll_event event, pid_t threadId)
Dispatch event to appropriate socket.
Definition: EPoll.cpp:95
int maxSockets
The maximum number of socket allowed.
Definition: EPoll.h:98
Definition: Command.h:20
-
int getDescriptor()
Return the descriptor for the ePoll socket.
Definition: EPoll.cpp:107
-
int processCommand(std::string command, TCPSession *session, std::stringstream &data) override
Output the threads array to the console.
Definition: EPoll.cpp:111
+
void eventReceived(struct epoll_event event)
Dispatch event to appropriate socket.
+
int getDescriptor()
Return the descriptor for the ePoll socket.
Definition: EPoll.cpp:83
+
int processCommand(std::string command, TCPSession *session, std::stringstream &data) override
Output the threads array to the console.
Definition: EPoll.cpp:87
~EPoll()
Definition: EPoll.cpp:17
EPoll()
Definition: EPoll.cpp:8
bool registerSocket(Socket *socket)
Register a BMASocket for monitoring by BMAEPoll.
Definition: EPoll.cpp:71
diff --git a/html/Socket_8h_source.html b/html/Socket_8h_source.html index b302722..01a5e1b 100644 --- a/html/Socket_8h_source.html +++ b/html/Socket_8h_source.html @@ -95,7 +95,7 @@ $(function() {
67  int getDescriptor();
68 
78 
-
79  bool eventReceived(struct epoll_event event, pid_t threadId);
+
79  bool eventReceived(struct epoll_event event);
80 
84 
85  int write(std::string data);
@@ -113,8 +113,8 @@ $(function() {
109  virtual void onUnregistered();
110 
111  bool needsToWrite();
-
112 
-
113  bool active = false;
+
112 
+
113  bool reset = false;
114 
115  protected:
116 
@@ -184,12 +184,12 @@ $(function() {
int write(std::string data)
Definition: Socket.cpp:155
Definition: EPoll.h:31
virtual void onRegistered()
Called after the socket has been registered with epoll processing.
Definition: Socket.cpp:55
-
virtual void onDataReceived(std::string data)
Called when data is received from the socket.
Definition: Socket.cpp:99
+
virtual void onDataReceived(std::string data)
Called when data is received from the socket.
Definition: Socket.cpp:102
Socket(EPoll &ePoll, std::string text="")
Definition: Socket.cpp:8
-
bool eventReceived(struct epoll_event event, pid_t threadId)
Parse epoll event and call specified callbacks.
Definition: Socket.cpp:61
void shutdown(std::string text="unknown")
Definition: Socket.cpp:174
virtual void onRegister()
Called before the socket has registered with the epoll processing.
Definition: Socket.cpp:53
-
virtual void receiveData(char *buffer, int bufferLength)
Definition: Socket.cpp:107
+
bool eventReceived(struct epoll_event event)
Parse epoll event and call specified callbacks.
Definition: Socket.cpp:61
+
virtual void receiveData(char *buffer, int bufferLength)
Definition: Socket.cpp:110
virtual void onUnregistered()
Called when the socket has finished unregistering for the epoll processing.
Definition: Socket.cpp:59
Definition: Object.h:8
int getDescriptor()
Get the descriptor for the socket.
Definition: Socket.cpp:40
diff --git a/html/TCPSession_8h_source.html b/html/TCPSession_8h_source.html index 39cc1b7..67aa365 100644 --- a/html/TCPSession_8h_source.html +++ b/html/TCPSession_8h_source.html @@ -99,51 +99,56 @@ $(function() {
52 
58 
59  void sendToAll(SessionFilter filter);
-
60 
-
61  TCPServer &server;
-
62 
-
63  protected:
-
64 
-
68 
-
69  virtual void onRegistered() override;
-
70 
-
76 
-
77  virtual void onDataReceived(char *data, int len) override;
-
78 
-
85 
-
86  virtual void onLineReceived(std::string line);
-
87 
-
93 
-
94  virtual void onConnected();
+
60 
+
64 
+
65  void terminate();
+
66 
+
70 
+
71  TCPServer &server;
+
72 
+
73  protected:
+
74 
+
78 
+
79  virtual void onRegistered() override;
+
80 
+
86 
+
87  virtual void onDataReceived(char *data, int len) override;
+
88 
95 
-
102 
-
103  virtual void protocol(std::string data);
-
104 
-
105  private:
-
106  char *lineBuffer = NULL;
-
107  int lineBufferSize = 0;
-
108  std::mutex mtx;
-
109 
-
110  };
-
111 
-
112 }
-
113 
-
114 #endif
+
96  virtual void onLineReceived(std::string line);
+
97 
+
103 
+
104  virtual void onConnected();
+
105 
+
112 
+
113  virtual void protocol(std::string data);
+
114 
+
115  private:
+
116  char *lineBuffer = NULL;
+
117  int lineBufferSize = 0;
+
118  std::mutex mtx;
+
119  bool term = false;
+
120 
+
121  };
+
122 
+
123 }
+
124 
+
125 #endif
-
void send()
Definition: TCPSession.cpp:78
+
void send()
Definition: TCPSession.cpp:80
Definition: SessionFilter.h:10
Definition: TCPSession.h:23
virtual void protocol(std::string data)
Definition: TCPSession.cpp:18
-
virtual void onDataReceived(char *data, int len) override
Definition: TCPSession.cpp:33
+
virtual void onDataReceived(char *data, int len) override
Definition: TCPSession.cpp:35
Definition: EPoll.h:31
-
void sendToAll()
Definition: TCPSession.cpp:63
+
void sendToAll()
Definition: TCPSession.cpp:65
virtual void onLineReceived(std::string line)
Definition: TCPSession.cpp:57
std::stringstream out
Definition: TCPSession.h:37
virtual void onRegistered() override
Called after the socket has been registered with epoll processing.
Definition: TCPSession.cpp:25
Definition: Command.h:20
Definition: TCPSocket.h:20
virtual void output(std::stringstream &data)
Definition: TCPSession.cpp:14
-
virtual void onConnected()
Definition: TCPSession.cpp:31
+
virtual void onConnected()
Definition: TCPSession.cpp:33
Definition: TCPServer.h:24