Beispiel #1
0
        private void TargetTransferResources(NetworkConnection target, int port)
        {
            string[] files = Directory.GetFiles(PlayerPrefs.GetString("simSelectedRobot"));

            CmdSetNumRobotFiles(files.Length);

            TcpFileTransfer.SendFiles(MultiplayerNetwork.Instance.networkAddress, port, files);
        }
Beispiel #2
0
        public void TransferResources()
        {
            ReceivedFiles.Clear();
            LocalRobotFileCount = -1;
            transferProgress    = 0f;

            int port = FileTransferBasePort + id;

            TcpFileTransfer.ReceiveFiles(port, PlayerPrefs.GetString("RobotDirectory") + "\\" + robotName,
                                         OnServerFileReceived);

            TargetTransferResources(connectionToClient, port);
        }
Beispiel #3
0
        public void DistributeResources(HashSet <int> destinationIds)
        {
            List <string> networkAddresses = new List <string>();
            int           port             = FileTransferBasePort + id;

            foreach (PlayerIdentity identity in FindObjectsOfType <PlayerIdentity>()
                     .Where(p => p.id != LocalInstance.id && destinationIds.Contains(p.id)))
            {
                string ipv6 = identity.connectionToClient.address;
                networkAddresses.Add(ipv6.Substring(ipv6.LastIndexOf(':') + 1));
                identity.TargetReceiveFiles(identity.connectionToClient, port, "RobotDirectory", robotName);
            }

            if (networkAddresses.Any())
            {
                TcpFileTransfer.SendFiles(networkAddresses.ToArray(), port, Directory.GetFiles(RobotFolder));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Distributes the selected field to all given destinations.
        /// </summary>
        /// <param name="destinationIds"></param>
        private void DistributeField(HashSet <int> destinationIds)
        {
            List <string> networkAddresses = new List <string>();
            int           port             = PlayerIdentity.FileTransferBasePort - 1;

            string[] fieldFiles = Directory.GetFiles(PlayerPrefs.GetString("simSelectedField"));

            foreach (PlayerIdentity identity in FindObjectsOfType <PlayerIdentity>()
                     .Where(p => destinationIds.Contains(p.id)))
            {
                identity.dependencyCount += fieldFiles.Length;

                string ipv6 = identity.connectionToClient.address;
                networkAddresses.Add(ipv6.Substring(ipv6.LastIndexOf(':') + 1));
                identity.TargetReceiveFiles(identity.connectionToClient, port, "FieldDirectory", FieldName);
            }

            TcpFileTransfer.SendFiles(networkAddresses.ToArray(), port, fieldFiles);
        }
Beispiel #5
0
 public void TargetReceiveFiles(NetworkConnection target, int port, string playerPrefsDirectory, string folderName)
 {
     TcpFileTransfer.ReceiveFiles(port, PlayerPrefs.GetString(playerPrefsDirectory) + "\\" + folderName,
                                  OnClientFileReceived);
 }