static int viewer_deactivated_cb(struct client_node *client, void *data)
{
struct inst_info *inst = data;
+ unsigned int cmd = CMD_VIEWER_DISCONNECTED;
+ struct packet *packet;
DbgPrint("%d is deleted from the list of viewer of %s(%s)\n", client_pid(client), package_name(instance_package(inst)), instance_id(inst));
if (!eina_list_data_find(inst->client_list, client)) {
return DBOX_STATUS_ERROR_NOT_EXIST;
}
+ packet = packet_create_noack((const char *)&cmd, "sss", package_name(inst->info), inst->id, client_direct_addr(inst->client));
+ if (packet) {
+ if (slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0) < 0) {
+ ErrPrint("Failed to send request to slave: %s\n", package_name(inst->info));
+ /*!
+ * \note
+ * From now, packet is not valid. because the slave_rpc_request_only will destroy it if it fails;)
+ */
+ }
+ } else {
+ ErrPrint("Failed to create a packet\n");
+ }
+
inst->client_list = eina_list_remove(inst->client_list, client);
if (!inst->client_list && !inst->client) {
DbgPrint("Has no clients\n");
return client_send_event(inst, packet);
}
+/**
+ * \note
+ * this function will be called after checking the list.
+ * only if the client is not in the list, this will be called.
+ */
HAPI int instance_add_client(struct inst_info *inst, struct client_node *client)
{
+ struct packet *packet;
+ unsigned int cmd = CMD_VIEWER_CONNECTED;
+
if (inst->client == client) {
ErrPrint("Owner cannot be the viewer\n");
return DBOX_STATUS_ERROR_INVALID_PARAMETER;
return DBOX_STATUS_ERROR_FAULT;
}
+ packet = packet_create_noack((const char *)&cmd, "sss", package_name(inst->info), inst->id, client_direct_addr(inst->client));
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, viewer_deactivated_cb, inst);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
instance_ref(inst);
inst->client_list = eina_list_append(inst->client_list, client);
- return DBOX_STATUS_ERROR_NONE;
+
+ return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
}
HAPI int instance_del_client(struct inst_info *inst, struct client_node *client)
return result;
}
-static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_subscribed_group(pid_t pid, int handle, const struct packet *packet)
{
const char *cluster;
const char *category;
* \todo
* SUBSCRIBE cluster & sub-cluster for a client.
*/
- ret = client_subscribe(client, cluster, category);
+ ret = client_subscribe_group(client, cluster, category);
if (ret == 0) {
package_alter_instances_to_client(client, ALTER_CREATE);
}
return result;
}
-static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_unsubscribed_group(pid_t pid, int handle, const struct packet *packet)
{
const char *cluster;
const char *category;
* \todo
* UNSUBSCRIBE cluster & sub-cluster for a client.
*/
- ret = client_unsubscribe(client, cluster, category);
+ ret = client_unsubscribe_group(client, cluster, category);
if (ret == 0) {
package_alter_instances_to_client(client, ALTER_DESTROY);
}
},
{
.cmd = CMD_STR_SUBSCRIBE, /* pid, cluster, sub-cluster */
- .handler = client_subscribed,
+ .handler = client_subscribed_group,
},
{
.cmd = CMD_STR_UNSUBSCRIBE, /* pid, cluster, sub-cluster */
- .handler = client_unsubscribed,
+ .handler = client_unsubscribed_group,
},
{
.cmd = CMD_STR_DELETE_CLUSTER,