Logo Search packages:      
Sourcecode: capisuite version File versions  Download package

void Connection::send_block (  )  throw (CapiError,CapiWrongState,CapiExternalError,CapiMsgError) [protected]

called to send next block (2048 bytes) of file

The transmission will be controlled automatically by Connection, so you don't need to call this method directly. send_block() will automatically send as much packets as the configured window size (conf_send_buffers) permits.

Will call CallInterface::transmissionComplete() if the file was transferred completely.

Exceptions:
CapiWrongState Thrown when the the connection is not up completely (physical & logical)
CapiExternalError Thrown when no CallInterface is registered
CapiError Thrown on some internal errors
CapiMsgError Thrown by Capi::data_b3_req().

Definition at line 804 of file connection.cpp.

References buffer_start, buffers_used, call_if, capi, Capi::data_b3_req(), error, file_to_send, NACT, ncci, ncci_state, prefix(), send_buffer, and CallInterface::transmissionComplete().

Referenced by data_b3_conf(), and start_file_transmission().

{
      if (ncci_state!=NACT)
            throw CapiWrongState("unable to send file because connection is not established","Connection::send_block()");

      if (!file_to_send)
            throw CapiError("unable to play file because no input file is open","Connection::send_block()");

      if (buffers_used>=7)
            throw CapiError("unable to send file snippet because buffers are full","Connection::send_block()");

      bool file_completed=false;

      unsigned short buff_num=(buffer_start+buffers_used)%7; // buffer to store the next item

      int i=0;
      while (i<2048 && !file_completed) {
            if (!file_to_send->get(send_buffer[buff_num][i]))
                  file_completed=true;
            else
                  i++;
      }

      try {
            if (i>0) {
                  capi->data_b3_req(ncci,send_buffer[buff_num],i,buff_num,0); // can throw CapiMsgError. Propagate.
                  buffers_used++;
            }
      }
      catch (CapiMsgError e) {
            error << prefix() << "WARNING: Can't send data_b3_req. Message was: " << e << endl;
            if (file_completed) {
                  file_to_send->close();
                  delete file_to_send;
                  file_to_send=NULL;
            }
      }

      if (file_completed) {
            file_to_send->close();
            delete file_to_send;
            file_to_send=NULL;
            if (call_if)
                  call_if->transmissionComplete();
            else
                  throw CapiExternalError("no call control interface registered!","Connection::send_block()");
      }
}


Generated by  Doxygen 1.6.0   Back to index