コード例 #1
0
ファイル: mhegic.cpp プロジェクト: DragonStalker/mythtv
// signal from NetStream
void MHInteractionChannel::slotFinished(QObject *obj)
{
    NetStream* p = dynamic_cast< NetStream* >(obj);
    if (!p)
        return;

    QByteArray url = p->Url().toEncoded();

    if (p->GetError() == QNetworkReply::NoError)
    {
        LOG(VB_MHEG, LOG_DEBUG, LOC + QString("Finished %1").arg(url.constData()) );
    }
    else
    {
        LOG(VB_MHEG, LOG_WARNING, LOC + QString("Finished %1").arg(p->GetErrorString()) );
    }

    p->disconnect();

    QMutexLocker locker(&m_mutex);

    if (m_pending.remove(url.constData()) < 1)
        LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Finished %1 wasn't pending").arg(url.constData()) );
    m_finished.insert(url.constData(), p);
}
コード例 #2
0
ファイル: net.C プロジェクト: ArnaudGastinel/jot-lib
void 
Network::accept_stream(void) 
{
   NetStream *s = wait_for_connect();
   cerr << "Network   accept_stream from ---->" << s->name() << endl;
   add_stream(s);
   add_client(s);

   // notify observers
   notify_net(Network_obs::accept_str, s);
}
コード例 #3
0
ファイル: gp_net.cpp プロジェクト: hjqqq/Forever
	bool NetListener::pushRecvData (RakNet::Packet* pPkt, VP_NET_STREAM& vpNS)
	{
		VP_NET_STREAM::iterator pi = vpNS.begin () ;//新連線的
		while (pi != vpNS.end ())
		{
			NetStream* pNS = *pi ;
			if (pNS->checkID (pPkt->guid))
			{
				//是同一個
				pNS->pushRecvData (pPkt) ;
				return true ;
			}
			++ pi ;
		}

		return false ;
	}
コード例 #4
0
//----------------------------------------------------------------------
// GuildMember implementation
GuildMember::GuildMember(NetStream& netStream)
{
  m_name = netStream.readText();
  m_level = uint8_t(netStream.readUInt32());
  m_class = uint8_t(netStream.readUInt32());
  m_guildRank = netStream.readUInt32();
  m_lastOn = time_t(netStream.readUInt32());
  m_publicNote = netStream.readText();
  m_zoneInstance = netStream.readUInt16();
  m_zoneId = netStream.readUInt16();
}
コード例 #5
0
ファイル: netconnection.cpp プロジェクト: crafter2d/crafter2d
void NetConnection::send(NetAddress& client, const NetStream& stream, NetPackage::Reliability reliability)
{
   PackageHandle package(mAllocator);
   package->reset();
   package->setType(NetPackage::eEvent);
   package->setReliability(reliability);
   package->setNumber(client.packageNumber);
   package->setData(stream.getDataSize(), stream.getData());

   ASSERT(package->getType() == NetPackage::eEvent);

   // update the package numbering
   if ( ++client.packageNumber > MAX_PACKAGE_NUMBER )
      client.packageNumber = 0;

   try
   {
      send(client, *package);

      // when reliability is requested, save the package in the resend queue
      if ( reliability >= NetPackage::eReliableSequenced )
      {
         client.resendQueue.push_back(package);
      }
   }
   catch ( NetSocketException* pexception )
   {
      switch ( pexception->getError() )
      {
         case NetSocketException::eConnReset:
            {
               mClients.remove(client.index);
            }
            break;
      }
   }
}
コード例 #6
0
ファイル: net.C プロジェクト: ArnaudGastinel/jot-lib
int
NetStream::interpret()
{
   char    buff_[256], *buff = buff_;
   NETenum code;
   int     port;
   processing_ = 1;
   int     ret = 0;

   while (_in_queue.count()) {
      *this >> code;
      switch (code) {
            case NETadd_connection: {
               *this >> buff >> port;  
               NetStream *s = new NetStream(port, buff);
               if (s->fd() != -1)
                  network_->add_stream(s);
               network_->interpret(code, this);
            }
            brcase NETquit: {
               network_->interpret(code, this);
               network_->remove_stream(this);
               ret = 1;  // this return value should terminate this NetStream
            }
            brcase NETidentify :
               *this >> port;  
               set_port(port);
               if (network_->first_) {
                  cerr << "NetStream accepts server -->" << print_name()<<endl;
                  for (int i=0; i<network_->nStreams_; i++)  {
                     NetStream *s = network_->streams_[i];
                     if (s->port() != -1 && s != this) {
                        *this << NETadd_connection 
                              << s->name()
                              << s->port()
                              << NETflush;
                     }
                  }
               }
            brcase NETtext:
               *this >> buff;
               cerr << "(* " << print_name() << " *) " << buff << endl;
            brcase NETbroadcast: { 
               str_ptr flag;
               *this >> flag;
               int i;
               for (i = 0; i < tags_.num(); i++)
                  if (flag == tags_[i])
                     break; 
               if (i == tags_.num()) {
                  _in_queue.remove_all();
                  if (Config::get_var_bool("PRINT_ERRS",false,true))
                     cerr << "Ignoring broadcast " << flag << endl;
               }
            }
            brcase NETbarrier: network_->_at_barrier++;
            brdefault : 
               //XXX - Added a way to bail out of bad stream...
               if (network_->interpret(code, this)) return 1;
         }
   }
   processing_ = 0;

   return ret;
}
コード例 #7
0
ファイル: guildshell.cpp プロジェクト: xbackupx/showeqx
//----------------------------------------------------------------------
// GuildMember implementation
GuildMember::GuildMember(NetStream& netStream)
{
  // Null-terminated name
  m_name = netStream.readText();

  // 4 byte level
  m_level = uint8_t(netStream.readUInt32());

  // 4 byte banker flag (0 = no, 1 = banker, 2 = alt, 3 = alt banker)
  m_banker = uint8_t(netStream.readUInt32());
  if (m_banker > 1)
  {
      m_alt = 1;
  }
  else
  {
      m_alt = 0;
  }
  m_banker = m_banker % 2;

  // 4 byte class
  m_class = uint8_t(netStream.readUInt32());

  // 4 byte rank (0 = member, 1 = officer, 2 = leader)
  m_guildRank = netStream.readUInt32();

  // 4 byte date/time for last on
  m_lastOn = time_t(netStream.readUInt32());

  // 4 byte guild tribute on/off (0 = off, 1 = on)
  m_guildTributeOn = netStream.readUInt32();

  // 4 byte guild tribute total donated
  m_guildTributeDonated = netStream.readUInt32();

  // 4 byte guild tribute last donation timestamp
  m_guildTributeLastDonation = time_t(netStream.readUInt32());

  // 4 byte prospective member? flag (0=prospective, 1=full member) ??
  m_fullmember = netStream.readUInt32();

  // Null-terminated public note
  m_publicNote = netStream.readText();

  // 2 byte zoneInstance and zoneId for current zone
  m_zoneInstance = netStream.readUInt16();
  m_zoneId = netStream.readUInt16();
}