rw_status_t rwtasklet_register_uagent_client(rwuagent_client_info_ptr_t rwuagent_info)
{
  rw_status_t status;
  rwtasklet_info_ptr_t rwtasklet_info = rwuagent_info->rwtasklet_info;

  RW_CF_TYPE_VALIDATE(rwuagent_info, rwuagent_client_info_ptr_t);

  // Instantiate a Test service client and bind this to the client channel
  RW_UAGENT__INITCLIENT(&rwuagent_info->rwuacli);

  RW_ASSERT(rwtasklet_info->rwmsg_endpoint);

  // Create a client channel pointing at the Test service's path
  // Instantiate a Test service client and connect this to the client channel
  rwuagent_info->dest = rwmsg_destination_create(rwtasklet_info->rwmsg_endpoint,
                                                 RWMSG_ADDRTYPE_UNICAST,
                                                 RWUAGENT_PATH);
  RW_ASSERT(rwuagent_info->dest);

  // Create a client channel that rwcli uses to recieve messages
  rwuagent_info->cc = rwmsg_clichan_create(rwtasklet_info->rwmsg_endpoint);
  RW_ASSERT(rwuagent_info->cc);

  // Bind a single service for uagent
  rwmsg_clichan_add_service(rwuagent_info->cc, &rwuagent_info->rwuacli.base);

  // Bind this srvchan to rwsched's taskletized cfrunloop
  // This will result in events executing in the cfrunloop context
  // rwsched_CFRunLoopRef runloop = rwsched_tasklet_CFRunLoopGetCurrent(tenv.rwsched);
  status = rwmsg_clichan_bind_rwsched_cfrunloop(rwuagent_info->cc,
                                                rwtasklet_info->rwsched_tasklet_info);
  RW_ASSERT(status == RW_STATUS_SUCCESS);

  return status;
}
Exemple #2
0
static void init_client(rwmsg_perf_task_t *t) {
  printf("Task %d client starting, sending to path '%s'...\n", t->num, t->path);
  t->cc = rwmsg_clichan_create(t->ep);
  rwmsg_clichan_bind_rwsched_queue(t->cc, t->rws_q);
  t->sig = rwmsg_signature_create(t->ep, RWMSG_PAYFMT_RAW, 1, RWMSG_PRIORITY_DEFAULT);
  t->dest = rwmsg_destination_create(t->ep, RWMSG_ADDRTYPE_UNICAST, t->path);
  t->m = calloc(t->cfg.size, 1);
  RW_ASSERT(!t->feedme_defreg);
  if (!t->feedme_defreg && !t->cfg.nofeedme) {
    rwmsg_closure_t cb = { 
      .feedme = feedme_client,
      .ud = t
    };
    rwmsg_destination_feedme_callback(t->dest, &cb);
    t->feedme_defreg = TRUE;
  }