Move version reading/writing out of ConnParams
That object is just a container for the current state. Move the I/O
to the classes already doing such stuff.
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index efc26ac..846e97e 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -80,7 +80,12 @@
void SConnection::initialiseProtocol()
{
- cp.writeVersion(os);
+ char str[13];
+
+ sprintf(str, "RFB %03d.%03d\n", defaultMajorVersion, defaultMinorVersion);
+ os->writeBytes(str, 12);
+ os->flush();
+
state_ = RFBSTATE_PROTOCOL_VERSION;
}
@@ -104,13 +109,25 @@
void SConnection::processVersionMsg()
{
+ char verStr[13];
+ int majorVersion;
+ int minorVersion;
+
vlog.debug("reading protocol version");
- bool done;
- if (!cp.readVersion(is, &done)) {
+
+ if (!is->checkNoWait(12))
+ return;
+
+ is->readBytes(verStr, 12);
+ verStr[12] = '\0';
+
+ if (sscanf(verStr, "RFB %03d.%03d\n",
+ &majorVersion, &minorVersion) != 2) {
state_ = RFBSTATE_INVALID;
throw Exception("reading version failed: not an RFB client?");
}
- if (!done) return;
+
+ cp.setVersion(majorVersion, minorVersion);
vlog.info("Client needs protocol version %d.%d",
cp.majorVersion, cp.minorVersion);