public static bool Receive(TabCoordinator coordinator, ReceiverCoordinator gsaReceiverCoordinator, IProgress <SidSpeckleRecord> streamCreationProgress, IProgress <MessageEventArgs> loggingProgress, IProgress <string> statusProgress, IProgress <double> percentageProgress) { GSA.App.Settings.TargetLayer = coordinator.ReceiverTab.TargetLayer; GSA.App.Settings.Units = UnitEnumToString(coordinator.ReceiverTab.CoincidentNodeUnits); GSA.App.Settings.CoincidentNodeAllowance = coordinator.ReceiverTab.CoincidentNodeAllowance; var messenger = new ProgressMessenger(loggingProgress); coordinator.ReceiverTab.StreamListToSidRecords(); Func <string, string, SpeckleInterface.IStreamReceiver> streamReceiverCreationFn = ((url, token) => new SpeckleInterface.StreamReceiver(url, token, messenger)); if (!gsaReceiverCoordinator.Initialize(coordinator.Account.ServerUrl, coordinator.Account.Token, coordinator.ReceiverTab.ReceiverSidRecords, streamReceiverCreationFn, loggingProgress, statusProgress, percentageProgress)) { return(false); } gsaReceiverCoordinator.Trigger(null, null); //Unlike for sending, the command itself doesn't dispose of the (receiver) coordinator here, as in the case of continuous mode it needs to persist as it needs //a constant web socket connection coordinator.WriteStreamInfo(); return(true); }
public bool CLIReceiver(List <SidSpeckleRecord> savedReceiverStreamInfo) { //Ignore the saved receiver stream info for now - review? var receiverStreamInfo = new List <SidSpeckleRecord>(); var streamIds = arguments["streamIDs"].Split(new char[] { ',' }); foreach (string id in streamIds) { receiverStreamInfo.Add(new SidSpeckleRecord(id, null)); } HelperFunctions.SetSidSpeckleRecords(EmailAddress, RestApi, GSA.App.Proxy, receiverStreamInfo, null); GSA.App.Settings.TargetLayer = ((arguments.ContainsKey("layer")) && (arguments["layer"].ToLower() == "analysis")) ? GSATargetLayer.Analysis : GSATargetLayer.Design; if (arguments.ContainsKey("nodeAllowance") && double.TryParse(arguments["nodeAllowance"], out double nodeAllowance)) { GSA.App.Settings.CoincidentNodeAllowance = nodeAllowance; } //TO DO: enable is as a command line argument GSA.App.Settings.Units = "m"; var gsaReceiverCoordinator = new ReceiverCoordinator(); var nonBlankReceivers = receiverStreamInfo.Where(r => !string.IsNullOrEmpty(r.StreamId)).ToList(); /* * foreach (var streamInfo in nonBlankReceivers) * { * GSA.App.Messenger.Message(MessageIntent.Display, SpeckleGSAInterfaces.MessageLevel.Information, "Creating receiver " + streamInfo.StreamId); * var receiver = streamReceiverCreationFn(RestApi, ApiToken); * * gsaReceiverCoordinator.StreamReceivers[streamInfo.StreamId] = new SpeckleInterface.StreamReceiver(RestApi, ApiToken, ProgressMessenger); * } */ var messenger = new ProgressMessenger(new Progress <MessageEventArgs>()); //Func<string, string, SpeckleInterface.IStreamReceiver> streamReceiverCreationFn = ((url, token) => new SpeckleInterface.StreamReceiver(url, token, messenger)); if (!gsaReceiverCoordinator.Initialize(RestApi, ApiToken, nonBlankReceivers, streamReceiverCreationFn, new Progress <MessageEventArgs>(), new Progress <string>(), new Progress <double>())) { Console.WriteLine("Unable to set up connection with the server for the specified streams"); return(false); } HelperFunctions.SetSidSpeckleRecords(EmailAddress, RestApi, GSA.App.Proxy, receiverStreamInfo, null); gsaReceiverCoordinator.Trigger(null, null); gsaReceiverCoordinator.Dispose(); var filePath = arguments["file"]; if (filePath.StartsWith(".")) { string sCurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; filePath = Path.GetFullPath(Path.Combine(sCurrentDirectory, filePath)); } GSA.App.Proxy.SaveAs(filePath); GSA.App.Proxy.Close(); Console.WriteLine("Receiving complete"); return(true); }