Browse Source

modules/websockets: Added some extra debug/diagnostics

Peter Dunkley 13 years ago
parent
commit
b66cd6508d
1 changed files with 11 additions and 6 deletions
  1. 11 6
      modules/websocket/ws_frame.c

+ 11 - 6
modules/websocket/ws_frame.c

@@ -556,7 +556,7 @@ static int handle_pong(ws_frame_t *frame)
 
 
 int ws_frame_receive(void *data)
 int ws_frame_receive(void *data)
 {
 {
-	ws_frame_t ws_frame;
+	ws_frame_t frame;
 	tcp_event_info_t *tcpinfo = (tcp_event_info_t *) data;
 	tcp_event_info_t *tcpinfo = (tcp_event_info_t *) data;
 
 
 	update_stat(ws_received_frames, 1);
 	update_stat(ws_received_frames, 1);
@@ -567,21 +567,23 @@ int ws_frame_receive(void *data)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	switch(decode_and_validate_ws_frame(&ws_frame, tcpinfo))
+	switch(decode_and_validate_ws_frame(&frame, tcpinfo))
 	{
 	{
 	case OPCODE_TEXT_FRAME:
 	case OPCODE_TEXT_FRAME:
 	case OPCODE_BINARY_FRAME:
 	case OPCODE_BINARY_FRAME:
-		return receive_msg(ws_frame.payload_data, ws_frame.payload_len,
+		LM_DBG("Rx SIP message:\n%.*s\n", frame.payload_len,
+				frame.payload_data);
+		return receive_msg(frame.payload_data, frame.payload_len,
 				tcpinfo->rcv);
 				tcpinfo->rcv);
 
 
 	case OPCODE_CLOSE:
 	case OPCODE_CLOSE:
-		return handle_close(&ws_frame);
+		return handle_close(&frame);
 
 
 	case OPCODE_PING:
 	case OPCODE_PING:
-		return handle_ping(&ws_frame);
+		return handle_ping(&frame);
 
 
 	case OPCODE_PONG:
 	case OPCODE_PONG:
-		return handle_pong(&ws_frame);
+		return handle_pong(&frame);
 
 
 	default:
 	default:
 		LM_WARN("received bad frame\n");
 		LM_WARN("received bad frame\n");
@@ -606,6 +608,9 @@ int ws_frame_transmit(void *data)
 	frame.payload_data = wsev->buf;
 	frame.payload_data = wsev->buf;
 	frame.wsc = wsconn_get(wsev->id);
 	frame.wsc = wsconn_get(wsev->id);
 
 
+	LM_DBG("Tx SIP message:\n%.*s\n", frame.payload_len,
+			frame.payload_data);
+
 	if (encode_and_send_ws_frame(&frame, CONN_CLOSE_DONT) < 0)
 	if (encode_and_send_ws_frame(&frame, CONN_CLOSE_DONT) < 0)
 	{	
 	{	
 		LM_ERR("sending SIP message\n");
 		LM_ERR("sending SIP message\n");