Updated according to API changes

This commit is contained in:
Tatsuhiro Tsujikawa 2012-01-28 04:30:23 +09:00
parent a657208ffd
commit af4e977d6b
1 changed files with 31 additions and 12 deletions

View File

@ -211,20 +211,21 @@ void print_nv(char **nv)
} }
} }
static const char *ctrl_names[] = {
"SYN_STREAM",
"SYN_REPLY",
"RST_STREAM",
"SETTINGS",
"NOOP",
"PING",
"GOAWAY",
"HEADERS"
};
void on_ctrl_recv_callback void on_ctrl_recv_callback
(spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame, (spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame,
void *user_data) void *user_data)
{ {
static const char *ctrl_names[] = {
"SYN_STREAM",
"SYN_REPLY",
"RST_STREAM",
"SETTINGS",
"NOOP",
"PING",
"GOAWAY",
"HEADERS"
};
printf("recv %s frame ", ctrl_names[type-1]); printf("recv %s frame ", ctrl_names[type-1]);
switch(type) { switch(type) {
case SPDYLAY_SYN_REPLY: case SPDYLAY_SYN_REPLY:
@ -239,18 +240,35 @@ void on_ctrl_recv_callback
} }
void on_data_chunk_recv_callback void on_data_chunk_recv_callback
(spdylay_session *session, int32_t stream_id, uint8_t flags, (spdylay_session *session, uint8_t flags, int32_t stream_id,
const uint8_t *data, size_t len, void *user_data) const uint8_t *data, size_t len, void *user_data)
{} {}
void on_data_recv_callback void on_data_recv_callback
(spdylay_session *session, int32_t stream_id, uint8_t flags, int32_t length, (spdylay_session *session, uint8_t flags, int32_t stream_id, int32_t length,
void *user_data) void *user_data)
{ {
printf("recv DATA frame (stream_id=%d, flags=%d, length=%d)\n", printf("recv DATA frame (stream_id=%d, flags=%d, length=%d)\n",
stream_id, flags, length); stream_id, flags, length);
} }
void on_ctrl_send_callback
(spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame,
void *user_data)
{
printf("send %s frame ", ctrl_names[type-1]);
switch(type) {
case SPDYLAY_SYN_STREAM:
printf("(stream_id=%d, flags=%d, length=%d)\n",
frame->syn_stream.stream_id, frame->syn_stream.hd.flags,
frame->syn_stream.hd.length);
print_nv(frame->syn_stream.nv);
break;
default:
break;
}
}
void ctl_epollev(int epollfd, int op, SpdylayClient& sc) void ctl_epollev(int epollfd, int op, SpdylayClient& sc)
{ {
epoll_event ev; epoll_event ev;
@ -392,6 +410,7 @@ int run(const char *host, const char *service, const char *path)
callbacks.on_ctrl_recv_callback = on_ctrl_recv_callback; callbacks.on_ctrl_recv_callback = on_ctrl_recv_callback;
callbacks.on_data_chunk_recv_callback = on_data_chunk_recv_callback; callbacks.on_data_chunk_recv_callback = on_data_chunk_recv_callback;
callbacks.on_data_recv_callback = on_data_recv_callback; callbacks.on_data_recv_callback = on_data_recv_callback;
callbacks.on_ctrl_send_callback = on_ctrl_send_callback;
return communicate(host, service, path, &callbacks); return communicate(host, service, path, &callbacks);
} }