示例#1
0
void ipc_accept_loop(void *ipc, void *ipc_al_sthread) {

	int client_sd;
	void *ipcctrl_thread_arr = safe_array_init();

	while(sthread_isterminated(ipc_al_sthread) == 0) {

		safe_array_clean(ipcctrl_thread_arr, accept_loop_ipcctrl_thread_cnd);

		if ( -1 == (client_sd = ipcsocket_accept(ipc)) ) {
			break;
		} else {

			Tsthread_params stp;

			stp.execute = accept_loop_ipcctrl_execute;
			stp.finish = accept_loop_ipcctrl_finish;
			stp.user_data = new svr_ipcctrl(client_sd);
			stp.free_on_finish = 0;
			stp.initialize = NULL;

			safe_array_add(ipcctrl_thread_arr, sthread_run(&stp));

		}
	}

	safe_array_clean(ipcctrl_thread_arr, accept_loop_ipcctrl_thread_twt);
	safe_array_free(ipcctrl_thread_arr);

}
示例#2
0
void supla_client_locations::add_location(int Id, const char *Caption) {
	safe_array_lock(arr);

	if ( safe_array_findcnd(arr, arr_findcmp, &Id) == 0 ) {
		safe_array_add(arr, new supla_client_location(Id, Caption));
	}

	safe_array_unlock(arr);
}
示例#3
0
void supla_device_channels::add_channel(int Id, int Number, int Type, int Func, int Param1, int Param2, int Param3) {

	safe_array_lock(arr);

	if ( find_channel(Id) == 0 ) {
		safe_array_add(arr, new supla_device_channel(Id, Number, Type, Func, Param1, Param2, Param3));
	}

	safe_array_unlock(arr);

}
示例#4
0
void supla_client_channels::update_channel(int Id, int DeviceId, int LocationID, int Func, int Param1, const char *Caption) {

	safe_array_lock(arr);

	supla_client_channel *channel = NULL;

	if ( ( channel = find_channel(Id) ) == NULL ) {
		channel = new supla_client_channel(Id, DeviceId, LocationID, Func, Param1, Caption);
		safe_array_add(arr, channel);
	} else {
        channel->setCaption(Caption);
	}


	if ( channel ) {
		channel->mark_for_remote_update(CC_REMOTEUPDATE_CHANNEL);
	}


	safe_array_unlock(arr);

}
示例#5
0
void supla_device_channels::get_temp_and_humidity(void *tarr) {

	int a;
	safe_array_lock(arr);

	for(a=0;a<safe_array_count(arr);a++) {

		supla_device_channel *channel = (supla_device_channel *)safe_array_get(arr, a);

		if ( channel != NULL ) {

			   supla_channel_temphum *temphum = channel->getTempHum();

			   if ( temphum != NULL )
				   safe_array_add(tarr, temphum);
		}

	}

	safe_array_unlock(arr);

}
示例#6
0
void accept_loop(void *ssd, void *al_sthread) {

	void *supla_socket = NULL;
	void *svrconn_thread_arr = safe_array_init();


	while(sthread_isterminated(al_sthread) == 0) {

		safe_array_clean(svrconn_thread_arr, accept_loop_srvconn_thread_cnd);

		unsigned int ipv4;

		if ( ssocket_accept(ssd, &ipv4, &supla_socket) == 0  ) {
			break;
		} else {

			if ( supla_socket != NULL ) {

				Tsthread_params stp;

				stp.execute = accept_loop_srvconn_execute;
				stp.finish = accept_loop_srvconn_finish;
				stp.user_data = new serverconnection(ssd, supla_socket, ipv4);
				stp.free_on_finish = 0;
				stp.initialize = NULL;

				safe_array_add(svrconn_thread_arr, sthread_run(&stp));
			}

		}

	}

	safe_array_clean(svrconn_thread_arr, accept_loop_srvconn_thread_twt);
	safe_array_free(svrconn_thread_arr);
}