Showing the changes to interface/src/main.cpp (1 of 3 files). Show all
Unified · Split
| @@ -100,7 +100,7 @@ Cloud cloud(0, // Particles · 99 unmodified lines | ||
| 100 | 100 | false // Wrap |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | −VoxelSystem voxels(0, box); | |
| 103 | +VoxelSystem voxels(1000, box); | |
| 104 | 104 | |
| 105 | 105 | Lattice lattice(160,100); |
| 106 | 106 | Finger myFinger(WIDTH, HEIGHT); |
| @@ -230,6 +230,25 @@ void Timer(int extra) · 123 unmodified lines | ||
| 230 | 230 | int packet_size = strlen(output); |
| 231 | 231 | agentSocket.send(DOMAINSERVER_IP, DOMAINSERVER_PORT, output, packet_size); |
| 232 | 232 | |
| 233 | + // Ping the agents we can see | |
| 234 | + pingAgents(&agentSocket); | |
| 235 | + | |
| 236 | + if (0) { | |
| 237 | + // Massive send packet speed test | |
| 238 | + timeval starttest, endtest; | |
| 239 | + gettimeofday(&starttest, NULL); | |
| 240 | + char junk[1000]; | |
| 241 | + junk[0] = 'J'; | |
| 242 | + for (int i = 0; i < 3000; i++) | |
| 243 | + { | |
| 244 | + agentSocket.send("192.168.1.38", AGENT_UDP_PORT, junk, 1000); | |
| 245 | + } | |
| 246 | + gettimeofday(&endtest, NULL); | |
| 247 | + float sendTime = diffclock(&starttest, &endtest); | |
| 248 | + printf("packet test = %4.1f\n", sendTime); | |
| 249 | + } | |
| 250 | + | |
| 251 | + | |
| 233 | 252 | // Send a message to ourselves |
| 234 | 253 | //char test[]="T"; |
| 235 | 254 | //agentSocket.send("127.0.0.1", AGENT_UDP_PORT, test, 1); |
| @@ -520,7 +539,7 @@ void update_pos(float frametime) · 284 unmodified lines | ||
| 520 | 539 | const int MAX_BROADCAST_STRING = 200; |
| 521 | 540 | char broadcast_string[MAX_BROADCAST_STRING]; |
| 522 | 541 | int broadcast_bytes = myHead.getBroadcastData(broadcast_string); |
| 523 | − broadcast_to_agents(&agentSocket, broadcast_string, broadcast_bytes); | |
| 542 | + broadcastToAgents(&agentSocket, broadcast_string, broadcast_bytes); | |
| 524 | 543 | |
| 525 | 544 | //printf("-> %s\n", broadcast_string); |
| 526 | 545 | //dummyHead.recvBroadcastData(broadcast_string, broadcast_bytes); |
| @@ -773,14 +792,25 @@ void read_network() · 246 unmodified lines | ||
| 773 | 792 | { |
| 774 | 793 | sockaddr_in senderAddress; |
| 775 | 794 | int bytes_recvd; |
| 776 | − agentSocket.receive(&senderAddress, (void *)incoming_packet, &bytes_recvd); | |
| 777 | − | |
| 778 | − if (bytes_recvd > 0) | |
| 795 | + while (agentSocket.receive(&senderAddress, (void *)incoming_packet, &bytes_recvd)) | |
| 779 | 796 | { |
| 780 | 797 | packetcount++; |
| 781 | 798 | bytescount += bytes_recvd; |
| 782 | 799 | // If packet is a Mouse data packet, copy it over |
| 783 | − if (incoming_packet[0] == 'M') { | |
| 800 | + if (incoming_packet[0] == 'P') { | |
| 801 | + // | |
| 802 | + // Got Ping, reply immediately! | |
| 803 | + // | |
| 804 | + printf("Replying to ping!\n"); | |
| 805 | + char reply[] = "R"; | |
| 806 | + agentSocket.send(inet_ntoa(senderAddress.sin_addr), ntohs(senderAddress.sin_port), reply, 1); | |
| 807 | + } else if (incoming_packet[0] == 'R') { | |
| 808 | + // | |
| 809 | + // Got Reply, record as appropriate | |
| 810 | + // | |
| 811 | + setAgentPing(inet_ntoa(senderAddress.sin_addr), ntohs(senderAddress.sin_port)); | |
| 812 | + | |
| 813 | + } else if (incoming_packet[0] == 'M') { | |
| 784 | 814 | // |
| 785 | 815 | // mouse location packet |
| 786 | 816 | // |