本文整理汇总了C++中VectorBuffer::WriteString方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorBuffer::WriteString方法的具体用法?C++ VectorBuffer::WriteString怎么用?C++ VectorBuffer::WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorBuffer
的用法示例。
在下文中一共展示了VectorBuffer::WriteString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleNetworkMessage
void Chat::HandleNetworkMessage(StringHash eventType, VariantMap& eventData)
{
Network* network = GetSubsystem<Network>();
using namespace NetworkMessage;
int msgID = eventData[P_MESSAGEID].GetInt();
if (msgID == MSG_CHAT)
{
const PODVector<unsigned char>& data = eventData[P_DATA].GetBuffer();
// Use a MemoryBuffer to read the message data so that there is no unnecessary copying
MemoryBuffer msg(data);
String text = msg.ReadString();
// If we are the server, prepend the sender's IP address and port and echo to everyone
// If we are a client, just display the message
if (network->IsServerRunning())
{
Connection* sender = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
text = sender->ToString() + " " + text;
VectorBuffer sendMsg;
sendMsg.WriteString(text);
// Broadcast as in-order and reliable
network->BroadcastMessage(MSG_CHAT, true, true, sendMsg);
}
ShowChatText(text);
}
}
示例2: sizeof
PODVector<unsigned char> DecalSet::GetDecalsAttr() const
{
VectorBuffer ret;
ret.WriteBool(skinned_);
ret.WriteVLE(decals_.Size());
for (List<Decal>::ConstIterator i = decals_.Begin(); i != decals_.End(); ++i)
{
ret.WriteFloat(i->timer_);
ret.WriteFloat(i->timeToLive_);
ret.WriteVLE(i->vertices_.Size());
ret.WriteVLE(i->indices_.Size());
for (PODVector<DecalVertex>::ConstIterator j = i->vertices_.Begin(); j != i->vertices_.End(); ++j)
{
ret.WriteVector3(j->position_);
ret.WriteVector3(j->normal_);
ret.WriteVector2(j->texCoord_);
ret.WriteVector4(j->tangent_);
if (skinned_)
{
for (unsigned k = 0; k < 4; ++k)
ret.WriteFloat(j->blendWeights_[k]);
for (unsigned k = 0; k < 4; ++k)
ret.WriteUByte(j->blendIndices_[k]);
}
}
for (PODVector<unsigned short>::ConstIterator j = i->indices_.Begin(); j != i->indices_.End(); ++j)
ret.WriteUShort(*j);
}
if (skinned_)
{
ret.WriteVLE(bones_.Size());
for (Vector<Bone>::ConstIterator i = bones_.Begin(); i != bones_.End(); ++i)
{
ret.WriteString(i->name_);
ret.WriteUByte(i->collisionMask_);
if (i->collisionMask_ & BONECOLLISION_SPHERE)
ret.WriteFloat(i->radius_);
if (i->collisionMask_ & BONECOLLISION_BOX)
ret.WriteBoundingBox(i->boundingBox_);
ret.Write(i->offsetMatrix_.Data(), sizeof(Matrix3x4));
}
}
return ret.GetBuffer();
}
示例3:
PODVector<unsigned char> ScriptInstance::GetDelayedMethodCallsAttr() const
{
VectorBuffer buf;
buf.WriteVLE(delayedMethodCalls_.Size());
for (Vector<DelayedMethodCall>::ConstIterator i = delayedMethodCalls_.Begin(); i != delayedMethodCalls_.End(); ++i)
{
buf.WriteFloat(i->period_);
buf.WriteFloat(i->delay_);
buf.WriteBool(i->repeat_);
buf.WriteString(i->declaration_);
buf.WriteVariantVector(i->parameters_);
}
return buf.GetBuffer();
}
示例4: HandleSend
void Chat::HandleSend(StringHash eventType, VariantMap& eventData)
{
String text = textEdit_->GetText();
if (text.Empty())
return; // Do not send an empty message
Network* network = GetSubsystem<Network>();
Connection* serverConnection = network->GetServerConnection();
if (serverConnection)
{
// A VectorBuffer object is convenient for constructing a message to send
VectorBuffer msg;
msg.WriteString(text);
// Send the chat message as in-order and reliable
serverConnection->SendMessage(MSG_CHAT, true, true, msg);
// Empty the text edit after sending
textEdit_->SetText(String::EMPTY);
}
}
示例5: SendMessage
void GameEconomicServerClientConsole::SendMessage(String Message)
{
/// If sending message is empty
if (Message.Empty())
{
return; // Do not send an empty message
}
/// Get connection
Network* network = GetSubsystem<Network>();
Connection* serverConnection = network->GetServerConnection();
/// Send message only if serverconnection and connection is true
if (serverConnection&&serverconnection)
{
// A VectorBuffer object is convenient for constructing a message to send
VectorBuffer msg;
msg.WriteString(Message);
// Send the chat message as in-order and reliable
serverConnection->SendMessage(NetMessageAdminClientSend, true, true, msg);
}
return;
}