diff options
Diffstat (limited to 'protocols/Tox/src/tox_account.cpp')
-rw-r--r-- | protocols/Tox/src/tox_account.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp new file mode 100644 index 0000000000..9c59965bc7 --- /dev/null +++ b/protocols/Tox/src/tox_account.cpp @@ -0,0 +1,63 @@ +#include "common.h"
+#include "tox_bootstrap.h"
+
+void CToxProto::DoBootstrap()
+{
+ static int j = 0;
+ int i = 0;
+ while (i < 2)
+ {
+ struct bootstrap_node *d = &bootstrap_nodes[j % SIZEOF(bootstrap_nodes)];
+ tox_bootstrap_from_address(tox, d->address, TOX_ENABLE_IPV6_DEFAULT, d->port, d->key);
+ i++; j++;
+ }
+}
+
+void CToxProto::DoTox()
+{
+ uint32_t interval = 1000;
+ {
+ //mir_cslock lock(tox_lock);
+
+ tox_do(tox);
+ interval = tox_do_interval(tox);
+ }
+ Sleep(interval);
+}
+
+void CToxProto::PollingThread(void*)
+{
+ debugLogA("CToxProto::PollingThread: entering");
+
+ while (!isTerminated)
+ {
+ DoTox();
+ }
+
+ debugLogA("CToxProto::PollingThread: leaving");
+}
+
+void CToxProto::ConnectionThread(void*)
+{
+ debugLogA("CToxProto::ConnectionThread: entering");
+
+ while (!isTerminated && !isConnected)
+ {
+ DoBootstrap();
+
+ if (tox_isconnected(tox))
+ {
+ isConnected = true;
+ break;
+ }
+
+ DoTox();
+ }
+
+ if (!isTerminated && isConnected)
+ {
+ poolingThread = ForkThreadEx(&CToxProto::PollingThread, 0, NULL);
+ }
+
+ debugLogA("CToxProto::ConnectionThread: leaving");
+}
\ No newline at end of file |