87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
}
/*
* Send the reply back to the requestor, hopefully they are waiting for this message
*/
PostMessage(*reply);
delete message;
return;
}
virtual void HandleMessage(const pp::Var& messagePlain) {
pp::VarDictionary *message;
pp::Var target;
/*
* The incoming message must be a dictionary
*/
if (!messagePlain.is_dictionary()) {
pcscNaClHandleMessage(messagePlain);
return;
}
/*
* Process the appropriate command from the incoming message
*/
message = new pp::VarDictionary(messagePlain);
/*
* Verify that this message is destined for us
*/
if (!message->HasKey("target")) {
delete message;
pcscNaClHandleMessage(messagePlain);
return;
}
target = message->Get("target");
if (target.AsString() != "cackey") {
delete message;
pcscNaClHandleMessage(messagePlain);
return;
}
/*
* Determine what we are being asked to do
*/
if (!message->HasKey("command")) {
delete message;
pcscNaClHandleMessage(messagePlain);
return;
}
/*
* Process the request in another thread
*/
std::thread(&CACKeyInstance::HandleMessageThread, this, message).detach();
|