FACT++  1.0
int update_service_data ( char *  service,
int  conn_id,
int  subscribe,
int  req,
int  browser,
int  force 
)

Definition at line 718 of file webDid.c.

References sitem::buffer, sitem::buffer_size, sitem::buffer_str, sitem::buffer_str_size, sitem::conn_id, bitem::conn_id, create_browser(), delete_curr_service(), dic_info_service_stamped(), find_browser(), find_curr_service(), sitem::last_subscribed, bitem::last_subscribed, sitem::last_updated, bitem::last_updated, Memory::malloc(), MONITORED, sitem::n_browsers, sitem::name, no_link_int, recv_service_info(), sendData(), bitem::servicep, sitem::sid, sitem::size, sll_init(), sll_insert_queue(), sitem::str_size, time, sitem::timestamp, and update_command_data().

Referenced by sendData(), and sendSmiData().

719 {
720  CURR_SERVICE *servicep;
721  time_t tsecs;
722  void recv_service_info();
723  extern void sendData();
724  BROWSER *browserp;
725 
726  if(req){}
727  if(!Curr_service_head)
728  {
731  }
732  if(!(browserp = find_browser(browser)))
733  browserp = create_browser(browser);
734  if(force == -1)
735  {
736  update_command_data(service, conn_id, browserp);
737  return 1;
738  }
739  if((servicep = browserp->servicep))
740  {
741  servicep->n_browsers--;
742  if(!servicep->n_browsers)
743  delete_curr_service(servicep);
744  }
745  if(!(servicep = find_curr_service(service)))
746  {
747  servicep = (CURR_SERVICE *)malloc(sizeof(CURR_SERVICE));
748  strcpy(servicep->name,service);
749  servicep->conn_id = conn_id;
750  servicep->buffer = 0;
751  servicep->buffer_size = 0;
752  servicep->size = 0;
753  servicep->buffer_str = 0;
754  servicep->buffer_str_size = 0;
755  servicep->str_size = 0;
756  servicep->last_updated = 0;
757  tsecs = time((time_t *)0);
758  browserp->last_subscribed = tsecs;
759  browserp->last_updated = tsecs;
760  servicep->last_subscribed = tsecs;
761  servicep->n_browsers = 0;
762  sll_insert_queue((SLL *)Curr_service_head,(SLL *)servicep);
763  servicep->sid = (int)dic_info_service_stamped( service, MONITORED, subscribe, 0, 0,
764  recv_service_info, servicep, &no_link_int, 4);
765  }
766  else
767  {
768  if(servicep->size)
769  {
770  if((servicep->timestamp > browserp->last_updated) || (force))
771  {
772  sendData(conn_id, servicep->buffer_str, 4);
773  }
774  else
775  {
776  sendData(conn_id, "", 4);
777  }
778  browserp->last_updated = servicep->timestamp;
779  }
780  }
781  if(force)
782  {
783  browserp->servicep = servicep;
784  servicep->n_browsers++;
785  }
786  return 1;
787 }
int no_link_int
Definition: webDid.c:109
int n_browsers
Definition: webDid.c:44
unsigned dic_info_service_stamped(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size)
Definition: dic.c:613
Definition: webDid.c:30
CURR_SERVICE * servicep
Definition: webDid.c:73
#define MONITORED
Definition: dim_common.h:9
time_t last_subscribed
Definition: webDid.c:42
void * buffer_str
Definition: webDid.c:38
void * malloc()
Definition: EventBuilder.cc:99
int sid
Definition: webDid.c:33
int update_command_data(char *service, int conn_id, BROWSER *browserp)
Definition: webDid.c:696
CURR_SERVICE * Curr_service_head
Definition: webDid.c:46
time_t last_updated
Definition: webDid.c:66
time_t last_updated
Definition: webDid.c:43
Definition: dim.h:536
char name[MAX_NAME]
Definition: webDid.c:32
BROWSER * find_browser(int id)
Definition: webDid.c:253
void * buffer
Definition: webDid.c:34
void sll_init(SLL *head)
Definition: sll.c:14
int sll_insert_queue(SLL *head, SLL *item)
Definition: sll.c:20
int str_size
Definition: webDid.c:40
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
BROWSER * create_browser(int id)
Definition: webDid.c:663
CURR_SERVICE * find_curr_service(char *service)
Definition: webDid.c:238
int size
Definition: webDid.c:36
int buffer_str_size
Definition: webDid.c:39
int delete_curr_service(CURR_SERVICE *servicep)
Definition: webDid.c:612
void sendData(int conn_id, char *buffer, int type)
Definition: webServer.c:240
int buffer_size
Definition: webDid.c:35
void recv_service_info(void **tag, int *buffer, int *size)
Definition: webDid.c:870
time_t timestamp
Definition: webDid.c:37
time_t last_subscribed
Definition: webDid.c:65
Definition: webDid.c:61
int conn_id
Definition: webDid.c:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function: