https://cpp.hotexamples.com/examples/-/NetStream/-/cpp-netstream-class-examples.html
C++ (Cpp) NetStream - 7 examples found. These are the top rated real world C++ (Cpp) examples of NetStream extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
// 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);
}
Example #2
0
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);
}
Example #3
0
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 ;
}
Example #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();
}
Example #5
0
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;
}
}
}
Example #6
0
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;
}
Example #7
0
//----------------------------------------------------------------------
// 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();
}
'Development > C++' 카테고리의 다른 글
std::auto_ptr (0) | 2022.03.17 |
---|---|
'vsvars32.bat' (VsDevCmd.bat) equivalence of VS2019 and VS2015 (0) | 2022.03.17 |
C/C++ 자료형 (0) | 2022.03.16 |
[C++] _MSC_VER (0) | 2020.12.04 |
Signed vs Unsigned (0) | 2020.10.31 |