Browse Source

adding overrides

logicp 5 years ago
parent
commit
d040d26917
2 changed files with 10 additions and 2 deletions
  1. 4 2
      headers/socket_listener.hpp
  2. 6 0
      src/socket_listener.cpp

+ 4 - 2
headers/socket_listener.hpp

@@ -45,6 +45,8 @@ class SocketListener : public SendInterface {
 
   void sendMessage(int client_socket_fd, char* message, size_t size);
 
+  void sendMessage(int client_socket_fd, const char* message, size_t size);
+
   MessageHandler createMessageHandler(std::function<void()> cb);
   /**
    * Perform intialization work
@@ -67,8 +69,8 @@ class SocketListener : public SendInterface {
   // private methods
   int createSocket();
 
-  void onMessageReceived(int client_socket_fd,
-                         std::weak_ptr<char[]> w_buffer_ptr);
+  virtual void onMessageReceived(int client_socket_fd,
+                                 std::weak_ptr<char[]> w_buffer_ptr);
 
   int waitForConnection(int listening);
 

+ 6 - 0
src/socket_listener.cpp

@@ -59,6 +59,7 @@ SocketListener::MessageHandler SocketListener::createMessageHandler(
 
 void SocketListener::onMessageReceived(int client_socket_fd,
                                        std::weak_ptr<char[]> w_buffer_ptr) {
+  std::cout << "This should be overridden" << std::endl;
   sendMessage(client_socket_fd, w_buffer_ptr);
 }
 
@@ -96,6 +97,11 @@ void SocketListener::sendMessage(int client_socket_fd, char buffer[],
   send(client_socket_fd, buffer, size + 1, 0);
 }
 
+void SocketListener::sendMessage(int client_socket_fd, const char* buffer,
+                                 size_t size) {
+  send(client_socket_fd, buffer, size + 1, 0);
+}
+
 /**
  * init
  * TODO: Initialize buffer memory, if buffer is to be a class member