Add RFB server class implementation
Change-Id: I3532b5ecdef87cb8f64327de6bd22a175b68f865
Signed-off-by: Eddie James <eajames@linux.ibm.com>
diff --git a/ikvm_server.hpp b/ikvm_server.hpp
index 67602b0..ff51cfc 100644
--- a/ikvm_server.hpp
+++ b/ikvm_server.hpp
@@ -4,6 +4,10 @@
#include "ikvm_input.hpp"
#include "ikvm_video.hpp"
+#include <rfb/rfb.h>
+
+#include <vector>
+
namespace ikvm
{
@@ -53,6 +57,22 @@
Server(Server&&) = default;
Server& operator=(Server&&) = default;
+ /* @brief Resizes the RFB framebuffer */
+ void resize();
+ /* @brief Executes any pending RFB updates and client input */
+ void run();
+ /* @brief Sends pending video frame to clients */
+ void sendFrame();
+
+ /*
+ * @brief Indicates whether or not video data is desired
+ *
+ * @return Boolean to indicate whether any clients need a video frame
+ */
+ inline bool wantsFrame() const
+ {
+ return server->clientHead;
+ }
/*
* @brief Get the Video object
*
@@ -64,10 +84,38 @@
}
private:
+ /*
+ * @brief Handler for a client disconnecting
+ *
+ * @param[in] cl - Handle to the client object
+ */
+ static void clientGone(rfbClientPtr cl);
+ /*
+ * @brief Handler for client connecting
+ *
+ * @param[in] cl - Handle to the client object
+ */
+ static enum rfbNewClientAction newClient(rfbClientPtr cl);
+
+ /* @brief Performs the resize operation on the framebuffer */
+ void doResize();
+
+ /* @brief Boolean to indicate if a resize operation is on-going */
+ bool pendingResize;
+ /* @brief Number of frames handled since a client connected */
+ int frameCounter;
+ /* @brief Number of connected clients */
+ int numClients;
+ /* @brief Microseconds to process RFB events every frame */
+ long int processTime;
+ /* @brief Handle to the RFB server object */
+ rfbScreenInfoPtr server;
/* @brief Reference to the Input object */
Input& input;
/* @brief Reference to the Video object */
Video& video;
+ /* @brief Default framebuffer storage */
+ std::vector<char> framebuffer;
};
} // namespace ikvm