void P2PHTTPProxyServerSocket::ProcessInput(char* data, size_t* len)
{

  data[*len] = '\0';
  //LOG_P2P(BASIC_INFOR) << "------------------------";
  //LOG_P2P(BASIC_INFOR) << "Original data is ";
  //LOG_P2P(BASIC_INFOR) << "\n" << data;
  //LOG_P2P(BASIC_INFOR) << "------------------------";

  if(strncmp(HTTP_POST_HEADER,(const char *)data,
    HTTP_POST_HEADER_LENGTH) == 0){
      if(!ParseHTTPRequest(data,len,HTTP_POST_HEADER_LENGTH)){
        SignalCloseEvent(this,SOCKET_ERROR);
        return ;
      }
  }
  else if(strncmp(HTTP_GET_HEADER,(const char *)data,
    HTTP_GET_HEADER_LENGTH) == 0){
      if(!ParseHTTPRequest(data,len,HTTP_GET_HEADER_LENGTH)){
        SignalCloseEvent(this,SOCKET_ERROR);
        return ;
      }
  }

  //LOG_P2P(BASIC_INFOR) << "------------------------";
  //LOG_P2P(BASIC_INFOR) << "new data is ";
  //LOG_P2P(BASIC_INFOR) << "\n" << data;
  //LOG_P2P(BASIC_INFOR) << "------------------------";
  SignalConnectReadEvent(this,(const void *)data,*len);
}
Ejemplo n.º 2
0
 // AutoDetectProxy Slots
 void OnProxyDetectionComplete(SignalThread* thread) {
   ASSERT(detect_ == thread);
   Attach(factory_->CreateProxySocket(detect_->proxy(), type_));
   detect_->Release();
   detect_ = NULL;
   if (0 == AsyncSocketAdapter::Connect(remote_)) {
     SignalConnectEvent(this);
   } else if (!IsBlockingError(socket_->GetError())) {
     SignalCloseEvent(this, socket_->GetError());
   }
 }
Ejemplo n.º 3
0
P2PProxySocket::P2PProxySocket(P2PProxySession *p2p_proxy_session,
                               uint32 other_side_socket)
  :p2p_proxy_session_(p2p_proxy_session),connect_state_(CS_SOCKET_CONNECTING),
  other_side_socket_(other_side_socket),
  p2p_connection_implementator_(NULL)
{
  p2p_connection_management_ = P2PConnectionManagement::Instance();
  if(!p2p_proxy_session_->RegisterP2PProxySocket(this,false)){
    connect_state_ = CS_CLOSED;
    SetError(EALREADY);
    SignalCloseEvent(this,SOCKET_ERROR);
  }
  p2p_connection_implementator_ = 
    p2p_proxy_session_->GetP2PConnectionImplementator();
  ASSERT(p2p_connection_implementator_ != NULL);
  ASSERT(p2p_proxy_session_ != NULL);
}
void P2PRTSPProxyServerSocket::ProcessInput(char* data, size_t* len)
{
  data[*len] = '\0';
  //LOG_P2P(BASIC_INFOR) << "------------------------";
  //LOG_P2P(BASIC_INFOR) << "Original data is ";
  //LOG_P2P(BASIC_INFOR) << "\n" << data;
  //LOG_P2P(BASIC_INFOR) << "------------------------";
  if(strncmp(RTSP_HEADER,(const char *)data,RTSP_HEADER_LENGTH) == 0){
    if(!ParseRTSPRequest(data,len)){
      SignalCloseEvent(this,-1);
      return;
    }
  }
  BufferInput(false);
  SignalConnectReadEvent(this,(const void *)data,*len);
  BufferInput(true);
  *len = 0;
  /*BufferInput(false);
  SignalReadEvent(this);
  BufferInput(true);*/
}