当前位置: 首页>>代码示例>>C++>>正文


C++ PacketWriter::packetSize方法代码示例

本文整理汇总了C++中PacketWriter::packetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketWriter::packetSize方法的具体用法?C++ PacketWriter::packetSize怎么用?C++ PacketWriter::packetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PacketWriter的用法示例。


在下文中一共展示了PacketWriter::packetSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StartOSC

void CBodyBasics::StartOSC()
{
	// UDP stuff
	// RECEIVER
	recvsock.bindTo(RECVPORT);
	if (!recvsock.isOk()) {
		std::string s = "Error opening port " + std::to_string(RECVPORT) + ": " + recvsock.errorMessage() + "\n";
		printFucker(s);
	}
	else {
		std::string s = "Server started, will listen to packets on port " + std::to_string(RECVPORT) + "\n";
		printFucker(s);
	}


	// INITAL SENDER

	//sock.connectTo("localhost", 8000);
	clients[0].address = "localhost";
	clients[0].socket.connectTo("localhost", SENDPORT);
	clients[0].active = true;

	Message msg;
	PacketWriter pw;
	msg.init("/connected");
	pw.init();
	pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
	clients[0].socket.sendPacket(pw.packetData(), pw.packetSize());

}
开发者ID:rev3rend,项目名称:ITPKinect2OSC,代码行数:30,代码来源:TransmitData.cpp

示例2: connectToServer

void SoundManager::connectToServer(const String& serverIP, int serverPort)
{
	soundMsgSocket.connectTo(serverIP, 57110);
	soundMsgSocket.bindTo(8001); // Port to receive notify messages

	Message msg5("/notify");
	msg5.pushInt32(1);

	PacketWriter pw;
	pw.startBundle().addMessage(msg5).endBundle();
	soundMsgSocket.sendPacket(pw.packetData(), pw.packetSize());

	// Create socket and connect to OSC server
	soundServerSocket.connectTo(serverIP, serverPort);
	if (!soundServerSocket.isOk()) {
		ofmsg( "SoundManager: Error connection to port %1%: %2%", %serverPort %soundServerSocket.errorMessage() );
	} else {
开发者ID:guozanhua,项目名称:omicron,代码行数:17,代码来源:SoundManager.cpp

示例3: TransmitBody

void CBodyBasics::TransmitBody(INT64 nTime, int nBodyCount, IBody** ppBodies)
{
	// UDP
	Message msg;
	PacketWriter pw;
	bool ok;
	HRESULT hr;

	
	for (int cptr = 0; cptr < clients.size(); cptr++)
	{
		if (clients[cptr].active == 1) {
			//printFucker("sending to client " + clients[cptr].address + ": " + std::to_string(nBodyCount) + " bodies!\n");

			// SEND FRAME START OVER UDP
			msg.init("/beginFrame");
			msg.pushInt32(nBodyCount);
			pw.init();
			pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
			ok = clients[cptr].socket.sendPacket(pw.packetData(), pw.packetSize());


			for (int i = 0; i < nBodyCount; ++i)
			{
				IBody* pBody = ppBodies[i];
				if (pBody)
				{
					BOOLEAN bTracked = false;
					hr = pBody->get_IsTracked(&bTracked);

					if (SUCCEEDED(hr) && bTracked)
					{
						Joint joints[JointType_Count];
						D2D1_POINT_2F jointPoints[JointType_Count];
						HandState leftHandState = HandState_Unknown;
						HandState rightHandState = HandState_Unknown;

						pBody->get_HandLeftState(&leftHandState);
						pBody->get_HandRightState(&rightHandState);

						hr = pBody->GetJoints(_countof(joints), joints);
						if (SUCCEEDED(hr))
						{
							msg.init("/beginBody");
							msg.pushInt32(i);
							pw.init();
							pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
							ok = clients[cptr].socket.sendPacket(pw.packetData(), pw.packetSize());

							for (int j = 0; j < _countof(joints); ++j)
							{
								// /kinect body joint x y z
								msg.init("/bodyJoint");
								msg.pushInt32(i);
								msg.pushInt32(j);
								// body relative - joints[1] is spineMid which maps to Torso in OpenNI
								msg.pushFloat(joints[j].Position.X - joints[1].Position.X);
								msg.pushFloat(joints[j].Position.Y - joints[1].Position.Y);
								msg.pushFloat(joints[j].Position.Z - joints[1].Position.Z);
								// send message
								pw.init();
								pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
								ok = clients[cptr].socket.sendPacket(pw.packetData(), pw.packetSize());

							}

							msg.init("/endBody");
							msg.pushInt32(i);
							pw.init();
							pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
							ok = clients[cptr].socket.sendPacket(pw.packetData(), pw.packetSize());
						}


					}
				}
			}


			// SEND FRAME END OVER UDP
			msg.init("/endFrame");
			pw.init();
			pw.startBundle().startBundle().addMessage(msg).endBundle().endBundle();
			ok = clients[cptr].socket.sendPacket(pw.packetData(), pw.packetSize());


		}
	}

}
开发者ID:rev3rend,项目名称:ITPKinect2OSC,代码行数:90,代码来源:TransmitData.cpp


注:本文中的PacketWriter::packetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。