public static RosSocket ConnectToRos(Protocol protocolType, string serverUrl, EventHandler onConnected = null, EventHandler onClosed = null, RosSocket.SerializerEnum serializer = RosSocket.SerializerEnum.Microsoft) { IProtocol protocol = ProtocolInitializer.GetProtocol(protocolType, serverUrl); protocol.OnConnected += onConnected; protocol.OnClosed += onClosed; return(new RosSocket(protocol, serializer)); }
public ActionClient(TAction action, string actionName, string serverURL, Protocol protocol = Protocol.WebSocketSharp, RosSocket.SerializerEnum serializer = RosSocket.SerializerEnum.JSON, float timeStep = 0.2f) { this.action = action; this.actionName = actionName; this.timeStep = timeStep; this.serverURL = serverURL; socket = new RosSocket(ProtocolInitializer.GetProtocol(protocol, serverURL), serializer); }
public ActionServer(TAction action, string actionName, Protocol protocol, string serverURL, RosSocket.SerializerEnum serializer = RosSocket.SerializerEnum.JSON, int timeout = 10, float timeStep = 0.1f) { this.action = action; this.actionName = actionName; this.timeStep = timeStep; this.serverURL = serverURL; socket = new RosSocket(ProtocolInitializer.GetProtocol(protocol, serverURL), serializer); }
public ActionClient(TAction action, string actionName, string serverURL, Protocol protocol = Protocol.WebSocketSharp, RosSocket.SerializerEnum serializer = RosSocket.SerializerEnum.JSON, float secondsTimeout = 5f, float secondsTimestep = 0.2f) { this.action = action; this.actionName = actionName; this.millisecondsTimeout = (int)(secondsTimeout * 1000); this.millisecondsTimestep = (int)(secondsTimestep * 1000); this.serverURL = serverURL; socket = new RosSocket(ProtocolInitializer.GetProtocol(protocol, serverURL), serializer); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws Throwable public override void Start() { bool useEpoll = _useEpoll && Epoll.Available; ServerConfigurationProvider configurationProvider = useEpoll ? EpollConfigurationProvider.INSTANCE : NioConfigurationProvider.INSTANCE; _bossGroup = configurationProvider.CreateEventLoopGroup(1, _tf); // These threads handle live channels. Each thread has a set of channels it is responsible for, and it will // continuously run a #select() loop to react to new events on these channels. _selectorGroup = configurationProvider.CreateEventLoopGroup(_numSelectorThreads, _tf); // Bootstrap the various ports and protocols we want to handle foreach (KeyValuePair <BoltConnector, ProtocolInitializer> bootstrapEntry in _bootstrappersMap.SetOfKeyValuePairs()) { try { ProtocolInitializer protocolInitializer = bootstrapEntry.Value; BoltConnector boltConnector = bootstrapEntry.Key; ServerBootstrap serverBootstrap = CreateServerBootstrap(configurationProvider, protocolInitializer); ChannelFuture channelFuture = serverBootstrap.bind(protocolInitializer.Address().socketAddress()).sync(); InetSocketAddress localAddress = ( InetSocketAddress )channelFuture.channel().localAddress(); _connectionRegister.register(boltConnector.Key(), localAddress); string host = protocolInitializer.Address().Hostname; int port = localAddress.Port; if (host.Contains(":")) { // IPv6 _log.info("Bolt enabled on [%s]:%s.", host, port); } else { // IPv4 _log.info("Bolt enabled on %s:%s.", host, port); } } catch (Exception e) { // We catch throwable here because netty uses clever tricks to have method signatures that look like they do not // throw checked exceptions, but they actually do. The compiler won't let us catch them explicitly because in theory // they shouldn't be possible, so we have to catch Throwable and do our own checks to grab them throw new PortBindException(bootstrapEntry.Value.address(), e); } } }
/// <summary> /// Ritorna un nuovo oggetto ProtocolInitializer per la protocollazione automatica di una UDS /// </summary> public ProtocolInitializer GetProtocolInitializer(UDSDto dto) { ProtocolInitializer protInitializer = new ProtocolInitializer(); // Oggetto protInitializer.Subject = dto.UDSModel.Model.Subject.Value; if (dto.UDSModel.Model.ProtocolDirectionSpecified) { switch (dto.UDSModel.Model.ProtocolDirection) { case ProtocolDirectionType.None: break; case ProtocolDirectionType.In: { protInitializer.ProtocolType = -1; break; } case ProtocolDirectionType.Out: { protInitializer.ProtocolType = 1; break; } case ProtocolDirectionType.InternalOffice: { protInitializer.ProtocolType = 0; break; } default: break; } } // Classificazione if (dto.UDSModel.Model.Category.DefaultEnabled) { int idCategory = int.Parse(dto.UDSModel.Model.Category.IdCategory); protInitializer.Category = FacadeFactory.Instance.CategoryFacade.GetById(idCategory); } // Gestione documenti if (dto.UDSModel.Model.Documents != null) { // Documento principale ICollection <BiblosDocumentInfo> mainDocuments = FillUDSDocuments(dto.UDSModel.Model.Documents.Document); if (mainDocuments.Count > 0) { protInitializer.MainDocument = mainDocuments.FirstOrDefault(); } // Allegati ICollection <BiblosDocumentInfo> attachments = FillUDSDocuments(dto.UDSModel.Model.Documents.DocumentAttachment); if (attachments.Any()) { protInitializer.Attachments = attachments.Cast <DocumentInfo>().ToList(); } // Annessi ICollection <BiblosDocumentInfo> annexed = FillUDSDocuments(dto.UDSModel.Model.Documents.DocumentAnnexed); if (annexed.Any()) { protInitializer.Annexed = annexed.Cast <DocumentInfo>().ToList(); } } // Contatti protInitializer.Senders = new List <ContactDTO>(); protInitializer.Recipients = new List <ContactDTO>(); if (dto.UDSModel.Model.Contacts != null) { foreach (Contacts contact in dto.UDSModel.Model.Contacts) { ICollection <ContactDTO> contactDtos = FillUDSContacts(contact.ContactInstances).Concat(FillUDSContacts(contact.ContactManualInstances)).ToList(); if (contact.ContactType.Equals(Helpers.UDS.ContactType.Sender)) { protInitializer.Senders.AddRange(contactDtos); } else { protInitializer.Recipients.AddRange(contactDtos); } } } // Settori if (dto.UDSModel.Model.Authorizations != null && dto.UDSModel.Model.Authorizations.Instances != null) { IList <Data.Role> roles = new List <Data.Role>(); foreach (AuthorizationInstance auth in dto.UDSModel.Model.Authorizations.Instances) { Data.Role role = FacadeFactory.Instance.RoleFacade.GetById(auth.IdAuthorization); roles.Add(role); } protInitializer.Roles = roles; } return(protInitializer); }
public ProtocolInitializer GetProtocolInitializer(IReadOnlyCollection <TenantModel> tenantModels, ProtocolModel protocolModel, Collaboration collaboration, WorkflowProperty dsw_p_CollaborationSignSummaryTemplateId, WorkflowProperty dsw_a_Collaboration_GenerateSignSummary, WorkflowProperty dsw_p_ProposerRole, UDSDto udsDto) { ProtocolInitializer protInitializer = new ProtocolInitializer(); // Oggetto protInitializer.Subject = protocolModel.Object; // Protocol Type protInitializer.ProtocolType = protocolModel.ProtocolType.EntityShortId; //Note protInitializer.Notes = protocolModel.Note; //Protocollo protInitializer.DocumentProtocol = protocolModel.DocumentProtocol; //Date protInitializer.DocumentDate = protocolModel.DocumentDate; // Classificazione if (protocolModel.Category != null && protocolModel.Category.IdCategory.HasValue) { protInitializer.Category = FacadeFactory.Instance.CategoryFacade.GetById(protocolModel.Category.IdCategory.Value); } if (protocolModel.Container != null && protocolModel.Container.IdContainer.HasValue) { protInitializer.Containers = new List <Data.Container> { FacadeFactory.Instance.ContainerFacade.GetById(Convert.ToInt32(protocolModel.Container.IdContainer)) }; } if (protocolModel.DocumentTypeCode != null) { protInitializer.DocumentTypeLabel = FacadeFactory.Instance.TableDocTypeFacade.GetByCode(protocolModel.DocumentTypeCode).Description; } string owner = DocSuiteContext.Current.User.UserName; // Gestione documenti if (protocolModel.MainDocument != null && !string.IsNullOrEmpty(protocolModel.MainDocument.FileName) && (protocolModel.MainDocument.ContentStream != null || protocolModel.MainDocument.DocumentId.HasValue)) { protInitializer.MainDocument = SaveStream(owner, protocolModel.MainDocument); } // Allegati IEnumerable <DocumentModel> results = null; if (protocolModel.Attachments != null && (results = protocolModel.Attachments.Where(f => !string.IsNullOrEmpty(f.FileName) && (f.ContentStream != null || f.DocumentId.HasValue))).Any()) { protInitializer.Attachments = SaveStream(owner, results); } if (collaboration != null && dsw_p_CollaborationSignSummaryTemplateId != null && dsw_a_Collaboration_GenerateSignSummary != null && dsw_a_Collaboration_GenerateSignSummary.ValueBoolean.HasValue && dsw_a_Collaboration_GenerateSignSummary.ValueBoolean.Value && dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.HasValue && dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.Value != Guid.Empty) { TemplateDocumentRepository templateDocumentRepository = WebAPIImpersonatorFacade.ImpersonateFinder(new TemplateDocumentRepositoryFinder(tenantModels), (impersonationType, finder) => { finder.UniqueId = dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.Value; finder.EnablePaging = false; return(finder.DoSearch().SingleOrDefault()?.Entity); }); if (templateDocumentRepository != null) { BiblosChainInfo biblosChainInfo = new BiblosChainInfo(templateDocumentRepository.IdArchiveChain); DocumentInfo biblosDocumentInfo = biblosChainInfo.Documents.Single(f => !f.IsRemoved); List <BuildValueModel> buildValueModels = new List <BuildValueModel>(); buildValueModels.Add(new BuildValueModel() { IsHTML = false, Name = "oggetto", Value = protInitializer.Subject, }); DateTime signDate; string token; foreach (CollaborationSign item in collaboration.CollaborationSigns) { signDate = item.SignDate ?? item.LastChangedDate.Value.DateTime; token = signDate.DayOfWeek == DayOfWeek.Sunday ? "la" : "il"; buildValueModels.Add(new BuildValueModel() { IsHTML = false, Name = $"signer_info_{item.Incremental}", Value = $"{item.SignName} {token} {signDate.ToLongDateString()}", }); } buildValueModels = BuildValueProposerRole(dsw_p_ProposerRole, buildValueModels); buildValueModels = BuildValueUDS(udsDto, buildValueModels); byte[] pdf = Services.StampaConforme.Service.BuildPDF(biblosDocumentInfo.Stream, buildValueModels.ToArray(), string.Empty); if (protInitializer.Attachments == null) { protInitializer.Attachments = new List <DocumentInfo>(); } protInitializer.Attachments.Add(SaveStream(owner, pdf, "riepilogo_firmatari.pdf")); } } // Annessi results = null; if (protocolModel.Annexes != null && (results = protocolModel.Annexes.Where(f => !string.IsNullOrEmpty(f.FileName) && (f.ContentStream != null || f.DocumentId.HasValue))).Any()) { protInitializer.Annexed = SaveStream(owner, results); } // Contatti protInitializer.Senders = new List <Data.ContactDTO>(); protInitializer.Recipients = new List <Data.ContactDTO>(); if (protocolModel.ContactManuals != null && protocolModel.ContactManuals.Any()) { foreach (ProtocolContactManualModel protocolContactManualModel in protocolModel.ContactManuals) { Data.Contact contact = new Data.Contact(); contact.ContactType = new Data.ContactType(Data.ContactType.Aoo); contact.Description = protocolContactManualModel.Description; contact.CertifiedMail = protocolContactManualModel.CertifiedEmail; contact.EmailAddress = protocolContactManualModel.EMail; if (!string.IsNullOrEmpty(protocolContactManualModel.Address)) { contact.Address = new Data.Address(); contact.Address.Address = protocolContactManualModel.Address; } if (protocolContactManualModel.ComunicationType == ComunicationType.Sender) { protInitializer.Senders.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Manual)); } else { protInitializer.Recipients.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Manual)); } } } if (protocolModel.Contacts != null && protocolModel.Contacts.Any()) { foreach (ProtocolContactModel protocolContactModel in protocolModel.Contacts) { Data.Contact contact = FacadeFactory.Instance.ContactFacade.GetById(protocolContactModel.IdContact); if (protocolContactModel.ComunicationType == ComunicationType.Sender) { protInitializer.Senders.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Address)); } else { protInitializer.Recipients.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Address)); } } } return(protInitializer); }
private ServerBootstrap CreateServerBootstrap(ServerConfigurationProvider configurationProvider, ProtocolInitializer protocolInitializer) { return((new ServerBootstrap()).group(_bossGroup, _selectorGroup).channel(configurationProvider.ChannelClass).option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).option(ChannelOption.SO_REUSEADDR, true).childOption(ChannelOption.SO_KEEPALIVE, true).childHandler(protocolInitializer.ChannelInitializer())); }