本文整理汇总了C++中OutStream::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ OutStream::isValid方法的具体用法?C++ OutStream::isValid怎么用?C++ OutStream::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutStream
的用法示例。
在下文中一共展示了OutStream::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onReceive
// InStream::ReceiveHandler implementation
virtual void onReceive(const void* data, int size)
{
std::string key = remoteHost.keyStr();
if (os.isValid()) {
// -> already initialized
std::string s((char*) data, size);
printf("Received %d bytes from %s: %s\n", size, key.c_str(), s.c_str());
server.broadcastMessage(data, size);
} else {
// -> connect outstream
if (size == sizeof(ServiceId)) {
ServiceId service = *((ServiceId*) data);
printf("Received client callback service id %d from %s\n", service, key.c_str());
os = remoteHost.connect(service);
ready = true;
sendMessage("HELLO", 6);
} else {
// invalid init message
printf("Received invalid callback service id from %s\n", key.c_str());
is.reset();
server.removeConnection(this);
delete this;
return;
}
}
is.read(this);
}
示例2: onShutdown
// OutStream::ShutdownHandler implementation
virtual void onShutdown(bool success)
{
printf("Shut down %s.\n", (success) ? "successfully" : "failed");
if (os.isValid() && !success)
os.reset();
server.removeConnection(this);
delete this;
}
示例3: onReset
virtual void onReset()
{
// (InStream OR OutStream reset)
printf("Reset.\n");
is.reset();
if (os.isValid())
os.reset();
server.removeConnection(this);
}
示例4: sendMessage
void sendMessage(const void* data, int size)
{
if (os.isValid() && ready) {
// printf("sendMessage()\n");
ready = false;
os.write(data, size, this);
} else
printf("sendMessage(): %s not ready!\n", remoteHost.keyStr().c_str());
}