diff options
author | irungentoo <irungentoo@gmail.com> | 2014-02-09 09:43:16 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-02-09 09:43:16 -0500 |
commit | 7a2ed25d3622ea92be0a7e00dc0415d9f0e953a4 (patch) | |
tree | 500a7d5b78edfef6722a3ff5a76955508574b2b5 /testing/experiment | |
parent | c498c206ed8eb2bd24031ddbe10956ff8bc9a82d (diff) |
Astyled and removed some useless files.
Diffstat (limited to 'testing/experiment')
-rw-r--r-- | testing/experiment/group_chats_test.c | 105 | ||||
-rw-r--r-- | testing/experiment/group_chats_test1.c | 107 |
2 files changed, 0 insertions, 212 deletions
diff --git a/testing/experiment/group_chats_test.c b/testing/experiment/group_chats_test.c deleted file mode 100644 index 04fee327..00000000 --- a/testing/experiment/group_chats_test.c +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | #include "../../toxcore/group_chats.h" | ||
2 | #define NUM_CHATS 8 | ||
3 | |||
4 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | ||
5 | #define c_sleep(x) Sleep(1*x) | ||
6 | #else | ||
7 | #define c_sleep(x) usleep(1000*x) | ||
8 | #endif | ||
9 | Group_Chat *chats[NUM_CHATS]; | ||
10 | |||
11 | void print_close(Group_Close *close) | ||
12 | { | ||
13 | uint32_t i, j; | ||
14 | IP_Port p_ip; | ||
15 | printf("___________________CLOSE________________________________\n"); | ||
16 | |||
17 | for (i = 0; i < GROUP_CLOSE_CONNECTIONS; i++) { | ||
18 | printf("ClientID: "); | ||
19 | |||
20 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
21 | printf("%02hhX", close[i].client_id[j]); | ||
22 | } | ||
23 | |||
24 | p_ip = close[i].ip_port; | ||
25 | printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | ||
26 | ntohs(p_ip.port)); | ||
27 | printf("\nTimestamp: %llu", (long long unsigned int) close[i].last_recv); | ||
28 | printf("\n"); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | void print_group(Group_Chat *chat) | ||
33 | { | ||
34 | uint32_t i, j; | ||
35 | printf("-----------------\nClientID: "); | ||
36 | |||
37 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
38 | printf("%02hhX", chat->self_public_key[j]); | ||
39 | } | ||
40 | |||
41 | printf("\n___________________GROUP________________________________\n"); | ||
42 | |||
43 | for (i = 0; i < chat->numpeers; i++) { | ||
44 | printf("ClientID: "); | ||
45 | |||
46 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
47 | printf("%02hhX", chat->group[i].client_id[j]); | ||
48 | } | ||
49 | |||
50 | printf("\nTimestamp: %llu", (long long unsigned int) chat->group[i].last_recv); | ||
51 | printf("\nlast_pinged: %llu", (long long unsigned int) chat->group[i].last_pinged); | ||
52 | printf("\npingid: %llu", (long long unsigned int) chat->group[i].pingid); | ||
53 | printf("\n"); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | void print_message(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) | ||
58 | { | ||
59 | printf("%u: %s | %u\n", peer_number, message, length); | ||
60 | } | ||
61 | |||
62 | int main() | ||
63 | { | ||
64 | IP ip; | ||
65 | ip.uint32 = 0; | ||
66 | uint32_t i; | ||
67 | |||
68 | |||
69 | for (i = 0; i < NUM_CHATS; ++i) { | ||
70 | chats[i] = new_groupchat(new_networking(ip, 12745)); | ||
71 | |||
72 | if (chats[i] == 0) | ||
73 | exit(1); | ||
74 | |||
75 | networking_registerhandler(chats[i]->net, 48, &handle_groupchatpacket, chats[i]); | ||
76 | callback_groupmessage(chats[i], &print_message, 0); | ||
77 | } | ||
78 | |||
79 | printf("ok\n"); | ||
80 | IP_Port ip_port; | ||
81 | ip_port.ip.uint32 = 0; | ||
82 | ip_port.ip.uint8[0] = 127; | ||
83 | ip_port.ip.uint8[3] = 1; | ||
84 | ip_port.port = htons(12745); | ||
85 | |||
86 | for (i = 0; i < NUM_CHATS; ++i) { | ||
87 | group_newpeer(chats[0], chats[i]->self_public_key); | ||
88 | chat_bootstrap(chats[i], ip_port, chats[0]->self_public_key); | ||
89 | printf("%u\n", i); | ||
90 | } | ||
91 | |||
92 | while (1) { | ||
93 | for (i = 0; i < NUM_CHATS; ++i) { | ||
94 | networking_poll(chats[i]->net); | ||
95 | do_groupchat(chats[i]); | ||
96 | printf("%u\n", chats[i]->numpeers); | ||
97 | print_close(chats[i]->close); | ||
98 | print_group(chats[i]); | ||
99 | } | ||
100 | |||
101 | c_sleep(100); | ||
102 | } | ||
103 | |||
104 | return 0; | ||
105 | } | ||
diff --git a/testing/experiment/group_chats_test1.c b/testing/experiment/group_chats_test1.c deleted file mode 100644 index fc10ab64..00000000 --- a/testing/experiment/group_chats_test1.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | #include "../../toxcore/group_chats.h" | ||
2 | #include "../misc_tools.c" // hex_string_to_bin | ||
3 | |||
4 | #define NUM_CHATS 8 | ||
5 | |||
6 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | ||
7 | #define c_sleep(x) Sleep(1*x) | ||
8 | #else | ||
9 | #define c_sleep(x) usleep(1000*x) | ||
10 | #endif | ||
11 | Group_Chat *chat; | ||
12 | |||
13 | void print_close(Group_Close *close) | ||
14 | { | ||
15 | uint32_t i, j; | ||
16 | IP_Port p_ip; | ||
17 | printf("___________________CLOSE________________________________\n"); | ||
18 | |||
19 | for (i = 0; i < GROUP_CLOSE_CONNECTIONS; i++) { | ||
20 | printf("ClientID: "); | ||
21 | |||
22 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
23 | printf("%02hhX", close[i].client_id[j]); | ||
24 | } | ||
25 | |||
26 | p_ip = close[i].ip_port; | ||
27 | printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | ||
28 | ntohs(p_ip.port)); | ||
29 | printf("\nTimestamp: %llu", (long long unsigned int) close[i].last_recv); | ||
30 | printf("\n"); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | void print_group(Group_Chat *chat) | ||
35 | { | ||
36 | uint32_t i, j; | ||
37 | printf("-----------------\nClientID: "); | ||
38 | |||
39 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
40 | printf("%02hhX", chat->self_public_key[j]); | ||
41 | } | ||
42 | |||
43 | printf("\n___________________GROUP________________________________\n"); | ||
44 | |||
45 | for (i = 0; i < chat->numpeers; i++) { | ||
46 | printf("ClientID: "); | ||
47 | |||
48 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | ||
49 | printf("%02hhX", chat->group[i].client_id[j]); | ||
50 | } | ||
51 | |||
52 | printf("\nTimestamp: %llu", (long long unsigned int) chat->group[i].last_recv); | ||
53 | printf("\nlast_pinged: %llu", (long long unsigned int) chat->group[i].last_pinged); | ||
54 | printf("\npingid: %llu", (long long unsigned int) chat->group[i].pingid); | ||
55 | printf("\n"); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | void print_message(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) | ||
60 | { | ||
61 | printf("%u: %s | %u\n", peer_number, message, length); | ||
62 | } | ||
63 | |||
64 | int main(int argc, char *argv[]) | ||
65 | { | ||
66 | IP ip; | ||
67 | ip.uint32 = 0; | ||
68 | uint32_t i; | ||
69 | |||
70 | chat = new_groupchat(new_networking(ip, 12745)); | ||
71 | |||
72 | if (chat == 0) | ||
73 | exit(1); | ||
74 | |||
75 | networking_registerhandler(chat->net, 48, &handle_groupchatpacket, chat); | ||
76 | |||
77 | callback_groupmessage(chat, &print_message, 0); | ||
78 | |||
79 | printf("ok\n"); | ||
80 | IP_Port bootstrap_ip_port; | ||
81 | bootstrap_ip_port.port = htons(atoi(argv[2])); | ||
82 | /* bootstrap_ip_port.ip.c[0] = 127; | ||
83 | * bootstrap_ip_port.ip.c[1] = 0; | ||
84 | * bootstrap_ip_port.ip.c[2] = 0; | ||
85 | * bootstrap_ip_port.ip.c[3] = 1; */ | ||
86 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | ||
87 | |||
88 | uint8_t *bootstrap_id = hex_string_to_bin(argv[3]); | ||
89 | |||
90 | chat_bootstrap(chat, bootstrap_ip_port, bootstrap_id); | ||
91 | |||
92 | free(bootstrap_id); | ||
93 | |||
94 | while (1) { | ||
95 | |||
96 | networking_poll(chat->net); | ||
97 | do_groupchat(chat); | ||
98 | printf("%u ", chat->numpeers); | ||
99 | printf("%u\n", group_sendmessage(chat, "Install Gentoo", sizeof("Install Gentoo"))); | ||
100 | //print_close(chat->close); | ||
101 | // print_group(chat); | ||
102 | |||
103 | c_sleep(100); | ||
104 | } | ||
105 | |||
106 | return 0; | ||
107 | } | ||