Hash :
94046104
Author :
Thomas de Grivel
Date :
2020-02-24T15:19:27
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
#include <sys/types.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#ifdef WIN32
# include "../common/win32.h"
#else
# include <sys/socket.h>
#endif
#include "tcp.h"
#include "../common/broadcast.h"
#include "../common/transmit.h"
#include "servlist.h"
#include "client_message_server.h"
#include "client_message_server_scat.h"
#include "client_message_server_dupli.h"
#include "broadcast.h"
void * Bcast_thread (void *param)
{
pident *servlist = (pident*) param;
pw13cc_Bcast (servlist, NULL, NULL);
return NULL;
}
int main ()
{
FILE * ip_list;
int mode1,mode2,i;
ip_list = fopen("IP_server","w+");
/* TODO : recuperation de la liste des anciens serveurs */
fclose (ip_list);
pident tmp;
pthread_t thread_Bcast;
pthread_create(&thread_Bcast, NULL, Bcast_thread, &pw13_serverlist);
sleep (2);
tmp = pw13_serverlist;
while (tmp) {
if ( !tmp->connected ) {
tmp->connected = 1;
TCPinit (tmp);
}
tmp = tmp->suiv;
}
sleep(1);
tmp = pw13_serverlist;
mode1 = 1;
mode2 = 0;
/*
MODE 1 =
0 : 2 serveurs reagissent entre eux
1 : tous les serveurs font la meme serie de chose
MODE 2 =
0 : lisage d'un son sur tous les pc
1 : printf de l'osc sur tous les pc
*/
if (mode1) {
/* MODE 1 : tous les serveurs... */
while (tmp) {
if(tmp->connected)
{
printf("socket : %i server->socket : %i \n", tmp->socket, tmp->server->socket);
if (!mode2) {
/* MODE 1-1 : MUSIC */
/* demande de creation du patch sound_out */
pw13_cluster_client_create_path ("/sdl/mixer/sound_out",
"sound_out.pw13.p", tmp);
pw13_cluster_client_create_path ("/sdl/mixer/wav_out",
"wav_out.pw13.p", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->suiv->elem,
tmp->list_of_patch->suiv->suiv->elem,
"time", "next time", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->elem,
tmp->list_of_patch->suiv->elem,
"L", "L", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->elem,
tmp->list_of_patch->suiv->elem,
"R", "R", tmp);
printf ("\n\ndemande de start du patchwork\n\n");
pw13_cluster_client_dupli_ask_patchwork_start (tmp->pw, 0, tmp);
} else {
/* MODE 1-0 : PRINTF-OSC */
/* demande de creation du patch sin */
pw13_cluster_client_create_path ("/std/time/augend",
"augend.pw13.p", tmp);
printf ("demande de patch print a cree\n");
pw13_cluster_client_create_path ("/std/float/print",
"print.pw13.p", tmp);
printf ("demande de patch augend a cree\n");
pw13_cluster_client_create_path ("/std/float/osc",
"osc.pw13.p", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->suiv->suiv->elem,
tmp->list_of_patch->suiv->suiv->suiv->elem,
"t", "next time", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->suiv->elem,
tmp->list_of_patch->suiv->suiv->elem,
"()", "any", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->elem,
tmp->list_of_patch->suiv->elem,
"osc", "float", tmp);
printf ("\n\ndemande de start du patchwork\n\n");
pw13_cluster_client_dupli_ask_patchwork_start (tmp->pw, 0, tmp);
/*
printf("->STOP \n");
pw13_cluster_client_ask_patch_stop(tmp->list_of_patch->elem,tmp);
*/
/* demande d'arret du premier patch */
/*
}else {
printf("->STOP \n");
pw13_cluster_client_ask_patch_stop(tmp->list_of_patch->elem,tmp);
printf("->DESTROY \n");
pw13_cluster_client_destroy_path(tmp->list_of_patch->elem,tmp);
}
}
*/
}
}
tmp=tmp->suiv;
}
tmp = pw13_serverlist;
/*
while (1)
{
if (tmp->connected) {
pw13_cluster_client_ask_pump (tmp);
*/ /* printf ("Ask PumP \n"); *//*
}
tmp = tmp->suiv;
if (tmp == NULL)
tmp = pw13_serverlist;
}
*/
} else {
/* MODE 0 : 2 serveurs... */
/* MACHINE 1 = tmp | MACHINE 2 = tmp->suiv */
/* creation des patch */
printf("\n->CREATION DES PATCHS AUGEND ET PRINT SUR LA MACHINE 1\n");
pw13_cluster_client_create_path ("/std/time/augend",
"augend.pw13.p", tmp);
pw13_cluster_client_create_path ("/std/float/print",
"print.pw13.p", tmp);
printf("\n->CREATION DU PATCH OSC SUR LA MACHINE 2\n");
pw13_cluster_client_create_path ("/std/float/osc",
"osc.pw13.p", tmp->suiv);
/* connection des patchs augend a master et print a augend en local */
printf("\n->CONNECTION DU PATCH PRINT A AUGEND ET AUGEND A MASTER EN LOCAL SUR LA MACHINE 1\n");
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->suiv->elem,
tmp->list_of_patch->suiv->suiv->elem,
"t", "next time", tmp);
pw13_cluster_client_connect_path_local
(tmp->list_of_patch->elem,
tmp->list_of_patch->suiv->elem,
"()", "any", tmp);
/* connection des patchs osc a print en passant par le output patch */
printf("\n->CONNECTION DU PATCH OSC A PRINT EN PASSANT PAR LE OUTPUT PATCH\n");
pw13_cluster_client_scat_bind_path_input(tmp->list_of_patch->elem, tmp->suiv->list_of_patch->elem, "float", "osc", tmp->suiv->adresse, tmp);
/* start du patchwork sur la machine 1*/
printf("\n->START DU PATCHWORK SUR LA MACHINE 1\n");
pw13_cluster_client_dupli_ask_patchwork_start (tmp->pw, 0, tmp);
/* start du patch osc sur la machine 2*/
printf("\n->START DU PATCH OSC SUR LA MACHINE 2\n");
pw13_cluster_client_scat_ask_patch_start (tmp->suiv->list_of_patch->elem, 0, tmp);
/* PUMP ifois SUR LA MACHINE 1 */
for (i = 1; i>0; i--) {
printf ("\n->ASK PUMP SUR LA MACHINE 1\n");
}
}
return (0);
}