X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=blobdiff_plain;f=src%2Fafb-proto-ws.c;fp=src%2Fafb-proto-ws.c;h=10c06fcde5a9d88c4b9b2b7fa2c7fd09125fe706;hp=f19924fa71ada3d1bae8405b12c791e74085ef04;hb=f40979c718fa6fe6b571e133e1bf19fc90957298;hpb=ca0f859d96599c8ae295c85f825030c891969de1 diff --git a/src/afb-proto-ws.c b/src/afb-proto-ws.c index f19924fa..10c06fcd 100644 --- a/src/afb-proto-ws.c +++ b/src/afb-proto-ws.c @@ -67,6 +67,8 @@ For the purpose of handling events the server can: - push or broadcast data as an event + - signal unexpected event + */ /************** constants for protocol definition *************************/ @@ -78,6 +80,7 @@ For the purpose of handling events the server can: #define CHAR_FOR_EVT_PUSH 'P' /* server -> client */ #define CHAR_FOR_EVT_SUBSCRIBE 'X' /* server -> client */ #define CHAR_FOR_EVT_UNSUBSCRIBE 'x' /* server -> client */ +#define CHAR_FOR_EVT_UNEXPECTED 'U' /* client -> server */ #define CHAR_FOR_DESCRIBE 'D' /* client -> server */ #define CHAR_FOR_DESCRIPTION 'd' /* server -> client */ #define CHAR_FOR_TOKEN_ADD 'T' /* client -> server */ @@ -790,6 +793,11 @@ int afb_proto_ws_client_token_remove(struct afb_proto_ws *protows, uint16_t toke return client_send_cmd_id16_optstr(protows, CHAR_FOR_TOKEN_DROP, tokenid, NULL); } +int afb_proto_ws_client_event_unexpected(struct afb_proto_ws *protows, uint16_t eventid) +{ + return client_send_cmd_id16_optstr(protows, CHAR_FOR_EVT_UNEXPECTED, eventid, NULL); +} + int afb_proto_ws_client_call( struct afb_proto_ws *protows, const char *verb, @@ -1039,6 +1047,14 @@ static void server_on_token_drop(struct afb_proto_ws *protows, struct readbuf *r protows->server_itf->on_token_remove(protows->closure, tokenid); } +static void server_on_event_unexpected(struct afb_proto_ws *protows, struct readbuf *rb) +{ + uint16_t eventid; + + if (readbuf_uint16(rb, &eventid)) + protows->server_itf->on_event_unexpected(protows->closure, eventid); +} + /* on version offer */ static void server_on_version_offer(struct afb_proto_ws *protows, struct readbuf *rb) { @@ -1097,6 +1113,9 @@ static void server_on_binary_job(int sig, void *closure) case CHAR_FOR_TOKEN_DROP: server_on_token_drop(binary->protows, &binary->rb); break; + case CHAR_FOR_EVT_UNEXPECTED: + server_on_event_unexpected(binary->protows, &binary->rb); + break; case CHAR_FOR_VERSION_OFFER: server_on_version_offer(binary->protows, &binary->rb); break;