private void TranslateUDP(EN_UDP_PACKET_TYPE type, byte[] bytes) { if (type == EN_UDP_PACKET_TYPE.TRANSFORM) { EN_PacketTransform packet = EN_Protocol.BytesToObject <EN_PacketTransform>(bytes); GameObject go = EN_NetworkObject.Find(packet.packet_network_id); if (go != null) { go.GetComponent <EN_SyncTransformClient>().Translate(packet.tX, packet.tY, packet.tZ, packet.rX, packet.rY, packet.rZ, packet.vX, packet.vY, packet.vZ); } } }
private void TranslateUDP(IPEndPoint source, EN_UDP_PACKET_TYPE type, byte[] bytes) { if (type == EN_UDP_PACKET_TYPE.TRANSFORM) { EN_PacketTransform packet = EN_Protocol.BytesToObject <EN_PacketTransform>(bytes); // This comes in as a Unity InstanceID, we need to networkID-it packet.packet_network_id = networkIDs[packet.packet_network_id]; byte[] bytes_data = EN_Protocol.ObjectToBytes(packet); BroadcastUDP(source, bytes_data); } }
private void ReceiveUDP(int loops) { if (udp_server.Available > 0) { byte[] bytes = udp_server.Receive(ref udp_source); //TODO: If Receive fails again after DC, try {} catch {} and spit it into console if (bytes.Length > 0) { // Get & translate first 4 bytes EN_UDP_PACKET_TYPE packet_type = EN_Protocol.BytesToUDPType(bytes); TranslateUDP(udp_source, packet_type, bytes); } } }
private IEnumerator ReceiveUDP() { while (true) { while (udp_client.Available > 0) { byte[] bytes = udp_client.Receive(ref server); if (bytes.Length > 0) { EN_UDP_PACKET_TYPE type = EN_Protocol.BytesToUDPType(bytes); TranslateUDP(type, bytes); udpBytesIn += (uint)bytes.Length; } } yield return(null); } }