summaryrefslogtreecommitdiffstats
path: root/friendfinder/handler.c
blob: fad9b8b5b5768d33594f339d1110323fbae9277e (plain) (blame)
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
#include "pthread.h"

#include "msg_sender.h"
#include "sender.h"
#include "receiver.h"
#include "handler.h"

pthread_t msg_thread, sender_thread, receiver_thread;


void init_msg_thread(char *from, char *to)
{
	struct nick *nicknames = (struct nick*) malloc(sizeof(struct nick));
	nicknames->from = from;
	nicknames->to = to;

	pthread_create(&msg_thread, NULL, msg_main_loop, (void*) nicknames);

	printf("HANDLER: msg thread init...\n");
}

void init_receiver_thread(char *from)
{
	pthread_create(&receiver_thread, NULL, receiver_main, (void*) from);
	
	printf("HANDLER: receiver thread init...\n");
}

void init_sender_thread(char *from)
{
	pthread_create(&sender_thread, NULL, sender_main, (void*) from);

	printf("HANDLER: sender thread init...\n");
}

void close_threads()
{
	pthread_exit(NULL);
	printf("HANDLER: all threads are closed...\n");
}