have interface clients tell the avatar-mixer and voxel-server what their ID is

This commit is contained in:
Stephen Birarda 2013-05-07 11:44:27 -07:00
parent 722205682e
commit 4eeb1ed5b1
4 changed files with 27 additions and 22 deletions

View file

@ -69,17 +69,20 @@ int main(int argc, const char* argv[])
*broadcastPacket = PACKET_HEADER_BULK_AVATAR_DATA;
unsigned char* currentBufferPosition = NULL;
uint16_t agentID = 0;
while (true) {
if (agentList->getAgentSocket().receive(agentAddress, packetData, &receivedBytes)) {
switch (packetData[0]) {
case PACKET_HEADER_HEAD_DATA:
// add this agent if we don't have them yet
if (agentList->addOrUpdateAgent(agentAddress, agentAddress, AGENT_TYPE_AVATAR, agentList->getLastAgentId())) {
agentList->increaseAgentId();
}
// grab the agent ID from the packet
unpackAgentId(packetData + 1, &agentID);
// this is positional data from an agent
// add or update the agent in our list
agentList->addOrUpdateAgent(agentAddress, agentAddress, AGENT_TYPE_AVATAR, agentID);
// parse positional data from an agent
agentList->updateAgentWithData(agentAddress, packetData, receivedBytes);
currentBufferPosition = broadcastPacket + 1;

View file

@ -436,17 +436,22 @@ void updateAvatar(float frametime) {
myAvatar.setCameraAspectRatio(::viewFrustum.getAspectRatio());
myAvatar.setCameraNearClip(::viewFrustum.getNearClip());
myAvatar.setCameraFarClip(::viewFrustum.getFarClip());
// Send my stream of head/hand data to the avatar mixer and voxel server
unsigned char broadcastString[200];
*broadcastString = PACKET_HEADER_HEAD_DATA;
int broadcastBytes = myAvatar.getBroadcastData(broadcastString + 1);
broadcastBytes++;
AgentList *agentList = AgentList::getInstance();
const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER};
AgentList::getInstance()->broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2);
if (agentList->getOwnerID() >= 0) {
// if I know my ID, send head/hand data to the avatar mixer and voxel server
unsigned char broadcastString[200];
unsigned char* endOfBroadcastStringWrite = broadcastString;
*(endOfBroadcastStringWrite++) = PACKET_HEADER_HEAD_DATA;
endOfBroadcastStringWrite += packAgentId(endOfBroadcastStringWrite, agentList->getOwnerID());
endOfBroadcastStringWrite += myAvatar.getBroadcastData(endOfBroadcastStringWrite);
const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER};
AgentList::getInstance()->broadcastToAgents(broadcastString, endOfBroadcastStringWrite - broadcastString, broadcastReceivers, 2);
}
// If I'm in paint mode, send a voxel out to VOXEL server agents.
if (::paintOn) {

View file

@ -128,8 +128,8 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
// called on the other agents - assigns it to my views of the others
int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
// increment to push past the packet header
sourceBuffer++;
// increment to push past the packet header and agent ID
sourceBuffer += 3;
unsigned char* startPosition = sourceBuffer;

View file

@ -547,12 +547,9 @@ int main(int argc, const char * argv[])
// If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_AVATAR, and we
// need to make sure we have it in our agentList.
if (packetData[0] == PACKET_HEADER_HEAD_DATA) {
if (agentList->addOrUpdateAgent(&agentPublicAddress,
&agentPublicAddress,
AGENT_TYPE_AVATAR,
agentList->getLastAgentId())) {
agentList->increaseAgentId();
}
uint16_t agentID = 0;
unpackAgentId(packetData + 1, &agentID);
agentList->addOrUpdateAgent(&agentPublicAddress, &agentPublicAddress, AGENT_TYPE_AVATAR, agentID);
agentList->updateAgentWithData(&agentPublicAddress, packetData, receivedBytes);
}