private static void Main(string[] args) { using (var client = new MessagingClient()) client.SendMessage("test message"); Console.WriteLine("Message sent. Press <ENTER> to exit."); Console.ReadLine(); }
protected override async Task OnJoinAsync(JoinEvent ev) { Log.WriteInfo($"SourceType:{ev.Source.Type}, SourceId:{ev.Source.Id}"); await MessagingClient.ReplyMessageAsync(ev.ReplyToken, $"Thank you for letting me join your {ev.Source.Type.ToString().ToLower()}!"); }
private Task EchoAsync(string replyToken, string userMessage) { return(MessagingClient.ReplyMessageAsync(replyToken, userMessage)); }
public Ping() { MessagingClient.SendMessageAsync <PingRequest, PingResponse>(null) .ReturnsForAnyArgs(GetCompletedTask(ExpectedResponse)); }
protected override async Task OnMessageAsync(MessageEvent ev) { var msg = ev.Message as TextEventMessage; if (msg == null) { return; } switch (msg.Text) { case "Rectangle-Cover": await ReplyButtonsTemplateMessageAsync(ImageAspectRatioType.Rectangle, ImageSizeType.Cover); break; case "Square-Contain": await ReplyButtonsTemplateMessageAsync(ImageAspectRatioType.Square, ImageSizeType.Contain); break; case "Square-Cover": await ReplyButtonsTemplateMessageAsync(ImageAspectRatioType.Square, ImageSizeType.Cover); break; case "Rectangle-Contein": default: await ReplyButtonsTemplateMessageAsync(ImageAspectRatioType.Rectangle, ImageSizeType.Contain); break; } async Task ReplyButtonsTemplateMessageAsync(ImageAspectRatioType imageAspectRatio, ImageSizeType imageSize) { var imageUri = BlobStorage.ListBlobUri(blobDirectoryName).FirstOrDefault(uri => uri.ToString().EndsWith(imageName)); if (imageUri == null) { imageUri = await BlobStorage.UploadImageAsync(Properties.Resources.sample_image, blobDirectoryName, imageName); } var actions = new[] { new MessageTemplateAction("Rectangle-Contain", "Rectangle-Contain"), new MessageTemplateAction("Rectangle-Cover", "Rectangle-Cover"), new MessageTemplateAction("Square-Contain", "Square-Contain"), new MessageTemplateAction("Square-Cover", "Square-Cover") }; var templateMessage = new TemplateMessage("ButtonsTemplate", new ButtonsTemplate( imageAspectRatio.ToString() + "-" + imageSize.ToString(), imageUri.ToString(), "Test of thumbnail image settings", actions, imageAspectRatio, imageSize, imageBackgroundColor: "#FF0000", defaultAction: new MessageTemplateAction("Default-Action", "Default-Action"))); await MessagingClient.ReplyMessageAsync(ev.ReplyToken, new[] { templateMessage }); } }
public void MessagingClient_DefaultCerificateStoreIsWindowsCerificateStore() { MessagingClient messagingClient = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry); Assert.IsInstanceOfType(messagingClient.CertificateStore, typeof(WindowsCertificateStore)); }
public void Asynchronous_ProcessingTasks_NotSet() { Settings.ServiceBus.Asynchronous.ProcessingTasks = 0; Client = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry, CertificateStore); }
public void Error_ReadTimeout_NotSet() { Settings.ServiceBus.Error.ReadTimeout = TimeSpan.Zero; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void AddressRegistry_NotSet() { Client = new MessagingClient(Settings, CollaborationRegistry, null); }
public void Error_ProcessingTasks_NotSet() { Settings.ServiceBus.Error.ProcessingTasks = 0; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void Error_TimeToLive_NotSet() { Settings.ServiceBus.Error.TimeToLive = TimeSpan.Zero; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void Options_NotSet() { Client = new MessagingClient(null, CollaborationRegistry, AddressRegistry); }
public void Asynchronous_ProcessingTasks_NotSet() { Settings.ServiceBus.Asynchronous.ProcessingTasks = 0; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
internal void SetupInternal(int otherHerId) { var addressRegistrySettings = new AddressRegistrySettings() { UserName = "******", Password = "******", EndpointName = "SomeEndpointName", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5) }; var collaborationRegistrySettings = new CollaborationProtocolRegistrySettings() { UserName = "******", Password = "******", EndpointName = "SomeEndpointName", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5) }; LoggerFactory = new LoggerFactory(); MockLoggerProvider = new MockLoggerProvider(null); LoggerFactory.AddProvider(MockLoggerProvider); Logger = LoggerFactory.CreateLogger <BaseTest>(); var distributedCache = DistributedCacheFactory.Create(); AddressRegistry = new AddressRegistryMock(addressRegistrySettings, distributedCache); AddressRegistry.SetupFindCommunicationPartyDetails(i => { var file = Path.Combine("Files", $"CommunicationDetails_{i}.xml"); return(File.Exists(file) == false ? null : XElement.Load(file)); }); AddressRegistry.SetupGetCertificateDetailsForEncryption(i => { var path = Path.Combine("Files", $"GetCertificateDetailsForEncryption_{i}.xml"); return(File.Exists(path) == false ? null : XElement.Load(path)); }); AddressRegistry.SetupGetCertificateDetailsForValidatingSignature(i => { var path = Path.Combine("Files", $"GetCertificateDetailsForValidatingSignature_{i}.xml"); return(File.Exists(path) == false ? null : XElement.Load(path)); }); CollaborationRegistry = new CollaborationProtocolRegistryMock(collaborationRegistrySettings, distributedCache, AddressRegistry); CollaborationRegistry.SetupFindProtocolForCounterparty(i => { var file = Path.Combine("Files", $"CPP_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); CollaborationRegistry.SetupFindAgreementForCounterparty(i => { var file = Path.Combine("Files", $"CPA_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); CollaborationRegistry.SetupFindAgreementById(i => { var file = Path.Combine("Files", $"CPA_{i:D}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); Settings = new MessagingSettings() { MyHerId = MockFactory.HelsenorgeHerId, SigningCertificate = new CertificateSettings() { StoreName = StoreName.My, StoreLocation = StoreLocation.LocalMachine, Thumbprint = TestCertificates.HelsenorgeSigntatureThumbprint }, DecryptionCertificate = new CertificateSettings() { StoreName = StoreName.My, StoreLocation = StoreLocation.LocalMachine, Thumbprint = TestCertificates.HelsenorgeEncryptionThumbprint } }; Settings.ServiceBus.ConnectionString = "connection string"; Settings.ServiceBus.Synchronous.ReplyQueueMapping.Add(Environment.MachineName.ToLower(), "RepliesGoHere"); // make things easier by only having one processing task per queue Settings.ServiceBus.Asynchronous.ProcessingTasks = 1; Settings.ServiceBus.Synchronous.ProcessingTasks = 1; Settings.ServiceBus.Error.ProcessingTasks = 1; MockFactory = new MockFactory(otherHerId); CertificateValidator = new MockCertificateValidator(); CertificateStore = new MockCertificateStore(); var signingCertificate = CertificateStore.GetCertificate(TestCertificates.HelsenorgeSigntatureThumbprint); var encryptionCertificate = CertificateStore.GetCertificate(TestCertificates.HelsenorgeEncryptionThumbprint); MessageProtection = new MockMessageProtection(signingCertificate, encryptionCertificate); Client = new MessagingClient( Settings, CollaborationRegistry, AddressRegistry, CertificateStore, CertificateValidator, MessageProtection ); Client.ServiceBus.RegisterAlternateMessagingFactory(MockFactory); Server = new MessagingServer( Settings, Logger, LoggerFactory, CollaborationRegistry, AddressRegistry, CertificateStore, CertificateValidator, MessageProtection ); Server.ServiceBus.RegisterAlternateMessagingFactory(MockFactory); }
public void Synchronous_ProcessingTasksEqualsZero_IsAllowed() { Settings.ServiceBus.Synchronous.ProcessingTasks = 0; Client = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry, CertificateStore); }
public void MyHerId_NotSet() { Settings.MyHerId = 0; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void Syncrhonous_CallTimeout_NotSet() { Settings.ServiceBus.Synchronous.CallTimeout = TimeSpan.Zero; Client = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry); }
public void SigningCertificate_NotSet() { Settings.SigningCertificate = null; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void Syncrhonous_ReplyQueue_NotSet() { Settings.ServiceBus.Synchronous.ReplyQueueMapping = new Dictionary <string, string>(); Client = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry); }
public void ConnectionString_NotSet() { Settings.ServiceBus.ConnectionString = null; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
public void Asynchronous_TimeToLive_NotSet() { Settings.ServiceBus.Asynchronous.TimeToLive = TimeSpan.Zero; Client = new MessagingClient(Settings, LoggerFactory, CollaborationRegistry, AddressRegistry, CertificateStore); }
public void Syncrhonous_TimeToLive_NotSet() { Settings.ServiceBus.Synchronous.TimeToLive = TimeSpan.Zero; Client = new MessagingClient(Settings, CollaborationRegistry, AddressRegistry); }
/// <summary> /// Initializes a new instance of the MessagingClientManager class. /// </summary> public MessagingClientManager() { this.messagingClient = new MessagingClient(new Guid(ApplicationId), true, new TimeSpan(TimerIntervalHours, TimerIntervalMinutes, TimerIntervalSeconds)); this.messagingClient.Start(); this.messagingClient.MessageReceived += new EventHandler<DeCurtis.Messaging.Common.MessageReceivedEventArgs>(this.MessagingClient_MessageReceived); }
public bool Connected() { return(MessagingClient.CanPing()); }