forked from Novators/libsqrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqrlClientAsync.cpp
More file actions
53 lines (47 loc) · 1.14 KB
/
SqrlClientAsync.cpp
File metadata and controls
53 lines (47 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/** \file SqrlClientAsync.cpp
*
* \author Adam Comley
*
* This file is part of libsqrl. It is released under the MIT license.
* For more details, see the LICENSE file included with this package.
**/
#include "sqrl_internal.h"
#include "SqrlClient.h"
#include "SqrlClientAsync.h"
#include "SqrlAction.h"
#include "SqrlUser.h"
#include "SqrlEntropy.h"
#include "gcm.h"
namespace libsqrl
{
SqrlClientAsync::SqrlClientAsync() : SqrlClient() {
this->myThread = new std::thread( SqrlClientAsync::clientThread );
}
SqrlClientAsync::~SqrlClientAsync() {
}
void SqrlClientAsync::onClientIsStopping() {
this->stopping = true;
if( this->myThread ) {
this->myThread->join();
delete this->myThread;
}
}
void SqrlClientAsync::clientThread() {
SqrlClientAsync *client = (SqrlClientAsync*)SqrlClient::getClient();
while( client && !client->stopping ) {
if( client->loop() ) {
if( client->rapid ) {
client->rapid = false;
} else {
sqrl_sleep( 50 );
}
} else {
sqrl_sleep( 100 );
}
}
while( !client->callbackQueue.empty() ) {
struct CallbackInfo *info = client->callbackQueue.pop();
delete info;
}
}
}