14 #include "inbandbytestream.h"
15 #include "inbandbytestreamdatahandler.h"
16 #include "messagesession.h"
18 #include "clientbase.h"
26 InBandBytestream::InBandBytestream( MessageSession *session, ClientBase *clientbase )
27 : MessageFilter( session ), m_clientbase( clientbase ),
28 m_inbandBytestreamDataHandler( 0 ), m_blockSize( 4096 ), m_sequence( -1 ),
29 m_lastChunkReceived( -1 ), m_open( true )
48 if( !m_inbandBytestreamDataHandler || !m_open )
62 if( sid.empty() || sid != m_sid )
72 std::stringstream str;
77 if( m_lastChunkReceived + 1 != sequence )
82 m_lastChunkReceived = sequence;
84 if( !data->
cdata().length() )
95 if( !m_open || !m_parent || !m_clientbase || data.length() > m_blockSize )
98 Tag *m =
new Tag(
"message" );
107 Tag *a =
new Tag( m,
"amp" );
109 Tag *r =
new Tag( a,
"rule" );
113 r =
new Tag( a,
"rule" );
118 m_clientbase->
send( m );
122 void InBandBytestream::closed()
126 if( m_inbandBytestreamDataHandler )
130 void InBandBytestream::close()
137 const std::string&
id = m_clientbase->
getID();
138 Tag *iq =
new Tag(
"iq" );
139 iq->addAttribute(
"type",
"set" );
140 iq->addAttribute(
"to", m_parent->
target().
full() );
141 iq->addAttribute(
"id",
id );
142 Tag *c =
new Tag( iq,
"close" );
143 c->addAttribute(
"sid", m_sid );
146 m_clientbase->
send( iq );
151 m_inbandBytestreamDataHandler = ibbdh;
156 m_inbandBytestreamDataHandler = 0;