From 27e1bcab9e6cdc4829096068de3ae5d2b2e72a5d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 28 Jan 2012 17:25:14 +0900 Subject: [PATCH] Added spdylay_before_ctrl_send_callback --- lib/includes/spdylay/spdylay.h | 10 ++++++++++ lib/spdylay_session.c | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/includes/spdylay/spdylay.h b/lib/includes/spdylay/spdylay.h index 3f8358ee..0e7617ac 100644 --- a/lib/includes/spdylay/spdylay.h +++ b/lib/includes/spdylay/spdylay.h @@ -221,6 +221,15 @@ typedef void (*spdylay_on_data_send_callback) (spdylay_session *session, uint8_t flags, int32_t stream_id, int32_t length, void *user_data); +/* + * Callback function invoked before frame |frame| of type |type| is + * sent. This may be useful, for example, to know the stream ID of + * SYN_STREAM frame, which is not assigned when it was queued. + */ +typedef void (*spdylay_before_ctrl_send_callback) +(spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame, + void *user_data); + typedef struct { spdylay_send_callback send_callback; spdylay_recv_callback recv_callback; @@ -229,6 +238,7 @@ typedef struct { spdylay_on_ping_recv_callback on_ping_recv_callback; spdylay_on_data_chunk_recv_callback on_data_chunk_recv_callback; spdylay_on_data_recv_callback on_data_recv_callback; + spdylay_before_ctrl_send_callback before_ctrl_send_callback; spdylay_on_ctrl_send_callback on_ctrl_send_callback; spdylay_on_data_send_callback on_data_send_callback; } spdylay_session_callbacks; diff --git a/lib/spdylay_session.c b/lib/spdylay_session.c index 44e736bf..4bab949e 100644 --- a/lib/spdylay_session.c +++ b/lib/spdylay_session.c @@ -519,7 +519,12 @@ int spdylay_session_send(spdylay_session *session) session->aob.item = item; session->aob.framebuf = framebuf; session->aob.framebuflen = framebuflen; - /* TODO Call before_send callback */ + /* Call before_send callback */ + if(item->frame_type != SPDYLAY_DATA && + session->callbacks.before_ctrl_send_callback) { + session->callbacks.before_ctrl_send_callback + (session, item->frame_type, item->frame, session->user_data); + } } data = session->aob.framebuf + session->aob.framebufoff; datalen = session->aob.framebuflen - session->aob.framebufoff;