]> git.zarvox.org Git - shareboard.git/commitdiff
Make client speak the redefined protocol to the server correctly.
authorDrew Fisher <drew.m.fisher@gmail.com>
Thu, 7 Oct 2010 20:28:00 +0000 (13:28 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Thu, 7 Oct 2010 20:28:00 +0000 (13:28 -0700)
Also, force enum to remain consistent.

action.h
connectionmanager.cpp

index 9e25722c85a6552a6a35700e188840c9457910b6..25ba71728cb1ec604f410d0da5187960ccb793ff 100644 (file)
--- a/action.h
+++ b/action.h
 class Action {
 public:
        enum Type {
-               INVALID,
-               UserJoin,
-               UserPart,
-               MouseMove,
-               DrawLine,
-               AddImage,
-               UserChat
+               INVALID=0,
+               UserJoin=1,
+               UserPart=2,
+               MouseMove=3,
+               DrawLine=4,
+               AddImage=5,
+               UserChat=6
        };
 
        Action();
index db02dfeb33f876b0da10d0240806c2ace9572144..0e4d498855c16bef1bc3a1826420d143979dad27 100644 (file)
@@ -40,9 +40,14 @@ void ConnectionManager::haveData() {
                quint16 t = 0; // Type
                QString timestring;
                textstream >> mesgID >> userID >> timestring >> t;
+               qDebug() << "Read line:";
+               qDebug() << "\tmesgID: "<< mesgID;
+               qDebug() << "\tuserID: "<< userID;
+               qDebug() << "\ttime  : "<< timestring;
+               qDebug() << "\ttype  : "<< t;
 
                // Validate input
-               QDateTime timestamp = QDateTime::fromString(timestring, "yyyy-MM-ddTHH-mm-ss.zzz");
+               QDateTime timestamp = QDateTime::fromString(timestring, "yyyy-MM-ddTHH:mm:ss.zzz");
                if(mesgID == -1 || userID == -1 || !timestamp.isValid() ) {
                        qWarning() << "Received invalid message from server; discarding.";
                        continue;
@@ -69,6 +74,7 @@ void ConnectionManager::haveData() {
                                action->mesgID = mesgID;
                                action->userID = userID;
                                action->timestamp = timestamp;
+                               qDebug() << "Update: got UserJoin:" << username << "joined";
                                break;
                                }
                        case Action::UserPart:
@@ -96,9 +102,8 @@ void ConnectionManager::haveData() {
                                }
                        case Action::DrawLine:
                                {
-                               /*
                                act = new DrawLineAction();
-                               action = static_cast<DrawLineAction*>(act);
+                               DrawLineAction* action = static_cast<DrawLineAction*>(act);
                                int red = 0;
                                int green = 0;
                                int blue = 0;
@@ -110,6 +115,10 @@ void ConnectionManager::haveData() {
                                        continue;
                                }
                                do {
+                                       qreal x = 0;
+                                       qreal y = 0;
+                                       textstream >> x >> y;
+                                       action->points.append(QPointF(x,y));
                                        // some stuff with the points
                                } while(textstream.status() == QTextStream::Ok);
                                action->color = QColor::fromRgb(red, green, blue);
@@ -117,20 +126,26 @@ void ConnectionManager::haveData() {
                                action->mesgID = mesgID;
                                action->userID = userID;
                                action->timestamp = timestamp;
-                               */
                                break;
                                }
                        case Action::AddImage:
                                {
-                               /*
                                act = new AddImageAction();
                                AddImageAction* action = static_cast<AddImageAction*>(act);
-                               // do somethin with the top-left point
+                               qreal x = 0;
+                               qreal y = 0;
+                               textstream >> x >> y;
+                               action->topLeft = QPointF(x,y);
                                // handle reading image data as base64-encoded binary, bleah
+                               QString im;
+                               textstream >> im;
+                               // im is a base64-encoded binary string.
+                               
+
+
                                action->mesgID = mesgID;
                                action->userID = userID;
                                action->timestamp = timestamp;
-                               */
                                break;
                                }
                        case Action::UserChat:
@@ -165,7 +180,7 @@ void ConnectionManager::haveData() {
 void ConnectionManager::onConnect() {
        qDebug() << "connection established";
        emit connected();
-       (*textStream) << "0 0 0 2 " << username << endl;
+       (*textStream) << "0 0 0 1 " << username << endl;
        qDebug() << "sent JoinAction";
 }