public void GetPackageVersions( string repositoryName, string packageNames) { XmlMessageListPackages listPackagesMessage = XmlMessageCreator.CreateXmlMessageListPackages(); List <string> packages = packageNames.Split(',').ToList <string>(); listPackagesMessage.AddRepositoryPackages(repositoryName, packages); // create packet PacketMessage packetMessage = new PacketMessage(PacketMessageType.C_LIST_PACKAGE_VERSIONS, 0, listPackagesMessage.ToByteArray()); byte[] packet = _packetManager.CreateMessage(packetMessage.GetMessageData()); // send _clientSocket.Send(packet); // get response int rec = _clientSocket.Receive(_socketBuffer); byte[] data = new byte[rec]; Array.Copy(_socketBuffer, data, rec); _packetManager.AddReceivedData(data); }
public void GetRepositoriesList() { // create PacketMessage packetMessage = new PacketMessage(PacketMessageType.C_LIST_PACKAGES, 0, null); byte[] packet = _packetManager.CreateMessage(packetMessage.GetMessageData()); // send _clientSocket.Send(packet); // get response int rec = _clientSocket.Receive(_socketBuffer); byte[] data = new byte[rec]; Array.Copy(_socketBuffer, data, rec); _packetManager.AddReceivedData(data); }
public bool GetPackage( string repositoryName, string packageName, string version) { // verify repository LocalRepository requestedRepository = _localRepositoryManager.LocalRepositories.FirstOrDefault( localRepository => localRepository.Name == repositoryName); if (requestedRepository != null) { XmlMessageGetPackage getPackageMessage = XmlMessageCreator.CreateXmlMessageGetPackage(repositoryName, packageName, version); // create packet PacketMessage packetMessage = new PacketMessage(PacketMessageType.C_GET_PACKAGE, 0, getPackageMessage.ToByteArray()); byte[] packet = _packetManager.CreateMessage(packetMessage.GetMessageData()); // setup package builder and send request _packetBuilder.StartReceiving(requestedRepository.Path); _clientSocket.Send(packet); // get response Console.WriteLine("INFO: Waiting for incoming data..."); do { int rec = _clientSocket.Receive(_socketBuffer); byte[] data = new byte[rec]; Array.Copy(_socketBuffer, data, rec); _packetManager.AddReceivedData(data); Thread.Sleep(10); // TODO must be removed }while (_packetBuilder.IsReceiving()); return(true); } else { return(false); } }