├── .gitattributes ├── .gitignore ├── .mailmap ├── LICENSE ├── README.md ├── appveyor.yml ├── azure-pipelines.yml └── src ├── .idea └── .idea.Lime │ └── .idea │ ├── .name │ ├── indexLayout.xml │ ├── projectSettingsUpdater.xml │ └── vcs.xml ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── .vscode ├── launch.json └── tasks.json ├── Lime.Benchmarks ├── DeserializeBenchmark.cs ├── Lime.Benchmarks.csproj ├── PipeTcpTransportBenchmark.cs ├── PipeWebsocketTransportBenchmark.cs ├── Program.cs ├── TcpTransportBenchmark.cs ├── TransportBenchmarkcsBase.cs └── WebsocketTransportBenchmark.cs ├── Lime.Cli ├── Actions │ ├── ActionBase.cs │ ├── CreateAccountAction.cs │ ├── CreateAccountOptions.cs │ ├── IAction.cs │ ├── ProcessCommandAction.cs │ ├── ProcessCommandOptions.cs │ ├── ReceiveMessageOptions.cs │ ├── SendCommandAction.cs │ ├── SendCommandOptions.cs │ ├── SendEnvelopeOptions.cs │ ├── SendMessageAction.cs │ └── SendMessageOptions.cs ├── Certificate │ └── CertificateResolver.cs ├── ConnectionInformation.cs ├── IConnectionOptions.cs ├── IOptions.cs ├── LICENSE.txt ├── Lime.Cli.csproj ├── Options.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Readme.md ├── VERIFICATION.txt ├── connection.json ├── lime-cli.nuspec └── publish.bat ├── Lime.Client.TestConsole.Installer └── Lime.Client.TestConsole.Installer.vdproj ├── Lime.Client.TestConsole ├── App.xaml ├── App.xaml.cs ├── Commands.json ├── Converters │ ├── Converters.xaml │ ├── DataOperationToBrushConverter.cs │ ├── IsErrorToBrushConverter.cs │ ├── IsRawToBrushConverter.cs │ └── ToStringConverter.cs ├── DesignData │ ├── EnvelopeDesignData.xaml │ ├── MainDesignData.xaml │ └── SessionDesignData.xaml ├── FileUtil.cs ├── Lime.Client.TestConsole.csproj ├── Macros │ ├── ApplyTransportOptionsMacro.cs │ ├── CleanGuestIdentityMacro.cs │ ├── CloseTransportMacro.cs │ ├── IMacro.cs │ ├── MacroAttribute.cs │ ├── NotifyMessageConsumedMacro.cs │ ├── NotifyMessageReceivedMacro.cs │ ├── ReplyPingMacro.cs │ ├── SendAuthenticatingExternalMacro.cs │ ├── SendAuthenticatingGuestMacro.cs │ ├── SendAuthenticatingKeyMacro.cs │ ├── SendAuthenticatingMacroBase.cs │ ├── SendAuthenticatingPlainMacro.cs │ ├── SendAuthenticatingTransportMacro.cs │ ├── SendNegotiatingNoneNoneMacro.cs │ ├── SendNegotiatingNoneTlsMacro.cs │ ├── SendSetPresenceAvailableIdentityMacro.cs │ ├── SendSetPresenceAvailableMacro.cs │ ├── SendTemplateMacroBase.cs │ ├── SetDomainMacro.cs │ ├── SetGuestIdentityMacro.cs │ ├── SetLocalNodeMacro.cs │ ├── SetNotificationEvent.cs │ ├── SetSessionDataMacro.cs │ └── SetSessionIdMacro.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Mvvm │ └── ObservableCollectionEx.cs ├── Properties │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Templates.txt ├── ValidationRules │ └── JsonEnvelopeValidationRule.cs ├── Variables.txt ├── ViewModels │ ├── EnvelopeViewModel.cs │ ├── MacroViewModel.cs │ ├── MainViewModel.cs │ ├── ProfileViewModel.cs │ ├── SessionViewModel.cs │ ├── StatusMessageViewModel.cs │ ├── TemplateViewModel.cs │ ├── UIHelper.cs │ └── VariableViewModel.cs ├── Views │ ├── ApplicationResourcesDictionary.xaml │ ├── EnvelopeView.xaml │ ├── EnvelopeView.xaml.cs │ ├── SessionView.xaml │ └── SessionView.xaml.cs └── lime.ico ├── Lime.Client.Windows ├── App.config ├── App.xaml ├── App.xaml.cs ├── ConversationWindow.xaml ├── ConversationWindow.xaml.cs ├── Converters │ ├── BooleanToBrushConverter.cs │ ├── BooleanToTextDecorationConverter.cs │ ├── BooleanToVisibilityConverter.cs │ ├── ChatStateToDescriptionConverter.cs │ ├── Converters.xaml │ ├── DataOperationToBrushConverter.cs │ ├── EventToColorConverter.cs │ ├── IdentityTypeConverter.cs │ ├── PresenceToColorConverter.cs │ └── PresenceToDescriptionConverter.cs ├── DesignData │ ├── ConversationDesignData.xaml │ ├── LoginDesignData.xaml │ ├── RosterDesignData.xaml │ └── TraceDesignData.xaml ├── Images │ ├── Images2.xaml │ ├── appbar.message.smiley.blue.ico │ ├── appbar.message.smiley.ico │ └── placeholder.png ├── Lime.Client.Windows.csproj ├── Lime.Client.Windows_TemporaryKey.pfx ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Mvvm │ ├── AsyncCommand.cs │ └── ObservableCollectionEx.cs ├── OpenWindowMessage.cs ├── Pages │ ├── Conversation.xaml │ ├── Conversation.xaml.cs │ ├── Login.xaml │ ├── Login.xaml.cs │ ├── MessageItemTemplateSelector.cs │ ├── Roster.xaml │ ├── Roster.xaml.cs │ ├── RosterConversation.xaml │ ├── RosterConversation.xaml.cs │ ├── Trace.xaml │ └── Trace.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.en-US.Designer.cs │ ├── Resources.en-US.resx │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Shared │ └── WindowsUtils.cs ├── TraceWindow.xaml ├── TraceWindow.xaml.cs ├── UserControls │ ├── ContactList.xaml │ ├── ContactList.xaml.cs │ ├── PresenceComboBox.xaml │ ├── PresenceComboBox.xaml.cs │ ├── RosterToolbar.xaml │ └── RosterToolbar.xaml.cs ├── ViewModels │ ├── ContactViewModel.cs │ ├── ConversationViewModel.cs │ ├── LoginViewModel.cs │ ├── MainViewModel.cs │ ├── MessageViewModel.cs │ ├── PageViewModelBase.cs │ ├── RosterConversationViewModel.cs │ ├── RosterViewModel.cs │ └── TraceViewModel.cs └── packages.config ├── Lime.Client.sln ├── Lime.Messaging ├── Contents │ ├── ChatState.cs │ ├── CopyAndPaste.cs │ ├── DeletedContent.cs │ ├── DocumentList.cs │ ├── DocumentSelect.cs │ ├── DocumentTuple.cs │ ├── External.cs │ ├── Input.cs │ ├── Invoice.cs │ ├── InvoiceItem.cs │ ├── InvoiceStatus.cs │ ├── Item.cs │ ├── Link.cs │ ├── Location.cs │ ├── MediaLink.cs │ ├── MessageDirection.cs │ ├── PaymentAddress.cs │ ├── PaymentMethod.cs │ ├── PaymentReceipt.cs │ ├── PlainText.cs │ ├── Reaction.cs │ ├── Redirect.cs │ ├── Reply.cs │ ├── Select.cs │ ├── SensitiveContainer.cs │ ├── SsmlText.cs │ └── WebLink.cs ├── DocumentTypeResolverExtensions.cs ├── Lime.Messaging.csproj └── Resources │ ├── Account.cs │ ├── Capability.cs │ ├── Contact.cs │ ├── ContactDocument.cs │ ├── Delegation.cs │ ├── Group.cs │ ├── Ping.cs │ ├── Presence.cs │ ├── Quota.cs │ ├── Receipt.cs │ └── UriTemplates.cs ├── Lime.Protocol.ConsoleTests ├── Lime.Protocol.ConsoleTests.csproj ├── Program.cs └── appsettings.json ├── Lime.Protocol.LoadTests ├── ChannelBaseLoadTests.cs ├── Lime.Protocol.LoadTests.csproj ├── Tcp │ ├── PipeTcpTransportLoadTests.cs │ └── TcpTransportLoadTests.cs ├── TransportLoadTestsBase.cs ├── WebSocket │ ├── BinaryWebSocketTransportLoadTests.cs │ ├── PipeWebSocketTransportLoadTests.cs │ └── WebSocketTransportLoadTests.cs ├── builder.json └── huge.json ├── Lime.Protocol.UnitTests.Common ├── Dummy.cs ├── Lime.Protocol.UnitTests.Common.csproj └── Network │ ├── TransportListenerTestsBase.cs │ └── TransportTestsBase.cs ├── Lime.Protocol.UnitTests ├── Client │ ├── ClientChannelBuilderTests.cs │ ├── ClientChannelTests.cs │ ├── EstablishedClientChannelBuilderTests.cs │ ├── MultiplexerClientChannelTests.cs │ └── OnDemandClientChannelTests.cs ├── EnvelopeTests.cs ├── IdentityTests.cs ├── Lime.Protocol.UnitTests.csproj ├── Lime.Protocol.UnitTests.snk ├── LimeUriTests.cs ├── Listeners │ ├── BufferedChannelListenerTests.cs │ ├── ChannelListenerTests.cs │ └── DataflowChannelListenerTests.cs ├── Network │ ├── ChannelBaseTests.cs │ ├── Modules │ │ └── ResendMessagesChannelModuleTests.cs │ ├── TransportBaseTests.cs │ └── X509CertificateInfo.cs ├── NodeTests.cs ├── Serialization │ ├── Models │ │ └── Schedule.cs │ ├── Newtonsoft │ │ └── EnvelopeSerializerTests.cs │ ├── StringJsonExtensions.cs │ ├── TestDocument.cs │ └── TypeUtilTests.cs ├── Server │ ├── AggregateTransportListenerTests.cs │ ├── ServerChannelTests.cs │ └── ServerTests.cs └── Tracing │ └── ActivityExtensionsTests.cs ├── Lime.Protocol ├── Client │ ├── ClientChannel.cs │ ├── ClientChannelBuilder.cs │ ├── ClientChannelExtensions.cs │ ├── EstablishedClientChannelBuilder.cs │ ├── IClientChannel.cs │ ├── IClientChannelBuilder.cs │ ├── IClientProxyFactory.cs │ ├── IEstablishedClientChannelBuilder.cs │ ├── IOnDemandClientChannel.cs │ ├── MultiplexerClientChannel.cs │ └── OnDemandClientChannel.cs ├── Command.cs ├── DictionaryDocument.cs ├── Document.cs ├── DocumentCollection.cs ├── DocumentContainer.cs ├── Envelope.cs ├── EnvelopeExtensions.cs ├── EnvelopeId.cs ├── EnvelopeType.cs ├── IDocument.cs ├── IDocumentContainer.cs ├── IIdentity.cs ├── INode.cs ├── Identity.cs ├── IdentityDocument.cs ├── Immutable │ ├── Identity.cs │ └── Node.cs ├── JsonDocument.cs ├── Lime.Protocol.csproj ├── LimeUri.cs ├── Listeners │ ├── BufferedChannelListener.cs │ ├── ChannelListener.cs │ ├── DataflowChannelListener.cs │ ├── EventChannelListener.cs │ └── IChannelListener.cs ├── MediaType.cs ├── Message.cs ├── Network │ ├── BufferOverflowException.cs │ ├── CancellableTransportDecorator.cs │ ├── CancellationTokenSourceExtensions.cs │ ├── ChannelBase.cs │ ├── ChannelCommandProcessor.cs │ ├── ChannelExtensions.cs │ ├── ChannelInformation.cs │ ├── CommandProcessorExtensions.cs │ ├── DeferralEventArgs.cs │ ├── EnvelopeEventArgs.cs │ ├── EnvelopePipe.cs │ ├── EnvelopeTooLargeException.cs │ ├── ExceptionEventArgs.cs │ ├── FailedChannelInformation.cs │ ├── IChannel.cs │ ├── IChannelCommandProcessor.cs │ ├── IChannelInformation.cs │ ├── IChannelModule.cs │ ├── ICommandChannel.cs │ ├── IEnvelopeContainer.cs │ ├── IEstablishedChannel.cs │ ├── IEstablishedReceiverChannel.cs │ ├── IEstablishedSenderChannel.cs │ ├── IMessageChannel.cs │ ├── INotificationChannel.cs │ ├── IReceiverChannel.cs │ ├── ISenderChannel.cs │ ├── ISessionChannel.cs │ ├── ITraceWriter.cs │ ├── ITransport.cs │ ├── ITransportInformation.cs │ ├── JsonBuffer.cs │ ├── LimeException.cs │ ├── Modules │ │ ├── ChannelModule.cs │ │ ├── ChannelModuleBase.cs │ │ ├── ExtractContainerMessageModule.cs │ │ ├── FillEnvelopeRecipientsChannelModule.cs │ │ ├── NotifyReceiptChannelModule.cs │ │ ├── RemotePingChannelModule.cs │ │ ├── ReplyPingChannelModule.cs │ │ ├── Resend │ │ │ ├── DiscardDeadMessageHandler.cs │ │ │ ├── IDeadMessageHandler.cs │ │ │ ├── IKeyProvider.cs │ │ │ ├── IMessageStorage.cs │ │ │ ├── KeyProvider.cs │ │ │ ├── MemoryMessageStorage.cs │ │ │ └── ResendMessagesChannelModule.cs │ │ └── ThroughputControlChannelModule.cs │ ├── ReceiverChannel.cs │ ├── SenderChannel.cs │ ├── SynchronizedTransportDecorator.cs │ ├── TraceWriter.cs │ ├── TransportBase.cs │ ├── TransportInformation.cs │ └── X509CertificateExtensions.cs ├── Node.cs ├── NodeDocument.cs ├── Notification.cs ├── PlainDocument.cs ├── Reason.cs ├── ReasonCodes.cs ├── Security │ ├── Authentication.cs │ ├── AuthenticationScheme.cs │ ├── ExternalAuthentication.cs │ ├── GuestAuthentication.cs │ ├── IAuthenticatableTransport.cs │ ├── KeyAuthentication.cs │ ├── PlainAuthentication.cs │ └── TransportAuthentication.cs ├── Serialization │ ├── DictionaryExtensions.cs │ ├── DocumentSerializer.cs │ ├── DocumentTypeResolver.cs │ ├── IDocumentSerializer.cs │ ├── IDocumentTypeResolver.cs │ ├── IEnvelopeSerializer.cs │ ├── JsonDocumentExtensions.cs │ ├── Newtonsoft │ │ ├── Converters │ │ │ ├── AuthenticationJsonConverter.cs │ │ │ ├── DocumentCollectionJsonConverter.cs │ │ │ ├── DocumentContainerJsonConverter.cs │ │ │ ├── DocumentJsonConverter.cs │ │ │ ├── IdentityJsonConverter.cs │ │ │ ├── JTokenExtensions.cs │ │ │ ├── LimeUriJsonConverter.cs │ │ │ ├── MediaTypeJsonConverter.cs │ │ │ ├── NodeJsonConverter.cs │ │ │ ├── SessionJsonConverter.cs │ │ │ └── StringBasedTypeJsonConverter.cs │ │ └── EnvelopeSerializer.cs │ ├── TypeUtil.cs │ └── TypeUtilEx.cs ├── Server │ ├── AggregateTransportListener.cs │ ├── AuthenticationResult.cs │ ├── INodeRegistry.cs │ ├── IServer.cs │ ├── IServerChannel.cs │ ├── IStartable.cs │ ├── IStoppable.cs │ ├── ITransportListener.cs │ ├── NodeRegistry.cs │ ├── Server.cs │ ├── ServerBuilder.cs │ ├── ServerChannel.cs │ ├── ServerChannelExtensions.cs │ └── TransportEventArgs.cs ├── Session.cs ├── SessionCompression.cs ├── SessionEncryption.cs ├── SessionState.cs ├── StringExtensions.cs ├── Tracing │ ├── ActivityExtensions.cs │ ├── LimeActivitySource.cs │ └── TraceContext.cs ├── TypeExtensions.cs ├── Util │ ├── AsyncCountdownEvent.cs │ ├── ChannelUtil.cs │ ├── DeferralManager.cs │ ├── ProducerConsumer.cs │ ├── RateGate.cs │ └── TaskUtil.cs └── UtilExtensions.cs ├── Lime.Sample.AspNetCore ├── Controllers │ └── ValuesController.cs ├── Lime.Sample.AspNetCore.csproj ├── Listeners │ ├── CommandListener.cs │ ├── MessageListener.cs │ └── NotificationListener.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json └── appsettings.json ├── Lime.Sample.Client ├── DebugTraceWriter.cs ├── Lime.Sample.Client.csproj └── Program.cs ├── Lime.Sample.Server ├── DebugTraceWriter.cs ├── Lime.Sample.Server.csproj └── Program.cs ├── Lime.Transport.AspNetCore.UnitTests ├── ChannelContextProviderTests.cs ├── FakeCommandListener.cs ├── FakeEnvelopeListener.cs ├── FakeMessageListener.cs ├── FakeNotificationListener.cs ├── HttpEndPointOptionsTests.cs ├── Lime.Transport.AspNetCore.UnitTests.csproj ├── Middlewares │ ├── FakePipeReader.cs │ ├── FakePipeWriter.cs │ ├── FakeRequestDelegate.cs │ ├── FakeWebSocket.cs │ ├── HttpMiddlewareTests.cs │ ├── HttpMiddlewareTestsBase.cs │ ├── TcpConnectionHandlerTests.cs │ └── WebSocketMiddlewareTests.cs ├── TestsBase.cs └── Transport │ ├── FakeTransport.cs │ ├── HttpContextChannelTests.cs │ ├── SenderChannelAdapterTests.cs │ └── TransportListenerTests.cs ├── Lime.Transport.AspNetCore ├── AuthenticationHandler.cs ├── ChannelContext.cs ├── ChannelContextProvider.cs ├── EndPointOptions.cs ├── HttpEndPointOptions.cs ├── ISenderChannel.cs ├── Lime.Transport.AspNetCore.csproj ├── LimeExtensions.cs ├── LimeOptions.cs ├── LimeOptionsSetup.cs ├── Listeners │ ├── CommandListenerBase.cs │ ├── ICommandListener.cs │ ├── IEnvelopeListener.cs │ ├── IMessageListener.cs │ ├── INotificationListener.cs │ ├── MessageListenerBase.cs │ └── NotificationListenerBase.cs ├── Middlewares │ ├── HttpMiddleware.cs │ ├── TcpConnectionHandler.cs │ └── WebSocketMiddleware.cs ├── RegistrationHandler.cs ├── Transport │ ├── ChannelProvider.cs │ ├── HttpContextChannel.cs │ ├── IChannelProvider.cs │ ├── Kestrel │ │ ├── DuplexPipeStream.cs │ │ ├── README.txt │ │ ├── TaskToApm.cs │ │ └── ValueTaskExtensions.cs │ ├── SenderChannelAdapter.cs │ ├── TcpClientAdapter.cs │ └── TransportListener.cs ├── TransportEndPoint.cs ├── TransportType.cs └── UnregistrationHandler.cs ├── Lime.Transport.Redis.UnitTests ├── Lime.Transport.Redis.UnitTests.csproj ├── Properties │ └── AssemblyInfo.cs ├── RedisFixture.cs └── RedisTransportTests.cs ├── Lime.Transport.Redis ├── ConnectionMultiplexerFactory.cs ├── IConnectionMultiplexerFactory.cs ├── Lime.Transport.Redis.csproj ├── Lime.Transport.Redis.nuspec ├── RedisTransport.cs └── RedisTransportListener.cs ├── Lime.Transport.Tcp.UnitTests ├── CertificateUtil.cs ├── Lime.Transport.Tcp.UnitTests.csproj ├── MockTcpTransportTests.cs ├── PipeTcpTransportListenerTests.cs ├── PipeTcpTransportTests.cs ├── TcpTransportListenerTests.cs ├── TcpTransportTests.cs └── X509CertificateInfo.cs ├── Lime.Transport.Tcp ├── ITcpClient.cs ├── Lime.Transport.Tcp.csproj ├── LimeTcpActivitySource.cs ├── PipeTcpTransport.cs ├── PipeTcpTransportListener.cs ├── TcpClientAdapter.cs ├── TcpTransport.cs └── TcpTransportListener.cs ├── Lime.Transport.WebSocket.UnitTests ├── Lime.Transport.WebSocket.UnitTests.csproj ├── PipeWebSocketTransportListenerTests.cs ├── PipeWebSocketTransportTests.cs ├── Properties │ └── AssemblyInfo.cs ├── WebSocketTransportListenerTests.cs └── WebSocketTransportTests.cs ├── Lime.Transport.WebSocket ├── ClientWebSocketTransport.cs ├── Kestrel │ └── KestrelWebSocketTransportListener.cs ├── Lime.Transport.WebSocket.csproj ├── Lime.Transport.WebSocket.nuspec ├── LimeWebSocketActivitySource.cs ├── PipeClientWebSocketTransport.cs ├── PipeServerWebSocketTransport.cs ├── PipeWebSocketTransport.cs ├── PipeWebSocketTransportListener.cs ├── ServerWebSocketTransport.cs ├── WebSocketTransport.cs ├── WebSocketTransportListener.cs └── X509CertificateInfo.cs └── Lime.sln /.mailmap: -------------------------------------------------------------------------------- 1 | André Bires 2 | André Minelli André C. O. Minelli 3 | Gabriel Nepomuceno -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.7.{build}-alpha 2 | image: Visual Studio 2017 3 | configuration: Release 4 | platform: Any CPU 5 | cache: src/packages 6 | branches: 7 | only: 8 | - master 9 | assembly_info: 10 | patch: true 11 | file: '**\AssemblyInfo.*' 12 | assembly_file_version: '{version}' 13 | assembly_version: '{version}' 14 | assembly_informational_version: '{version}' 15 | before_build: 16 | - ps: | 17 | function UpdateProjectVersion($xmlPath, $version) 18 | { 19 | $xml = [xml](get-content $xmlPath) 20 | $propertyGroup = $xml.Project.PropertyGroup | Where { $_.Version} 21 | $propertyGroup.Version = $version 22 | $xml.Save($xmlPath) 23 | } 24 | UpdateProjectVersion "$env:appveyor_build_folder/src/Lime.Protocol/Lime.Protocol.csproj" $env:appveyor_build_version 25 | UpdateProjectVersion "$env:appveyor_build_folder/src/Lime.Messaging/Lime.Messaging.csproj" $env:appveyor_build_version 26 | 27 | - dotnet restore src/Lime.sln 28 | build: 29 | parallel: true 30 | project: src/Lime.sln 31 | verbosity: normal 32 | test: 33 | assemblies: 34 | - '**\*Tests.dll' 35 | categories: 36 | except: 37 | - 'Redis' 38 | artifacts: 39 | - path: '**\Lime*.nupkg' 40 | deploy: 41 | - provider: NuGet 42 | api_key: 43 | secure: PXJBxwlPQNC3BnaP7QqLS+coPAD6PcnVD26OMaNEqM2Am0p8oT69ptO0y7G/nWBH 44 | skip_symbols: false -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | - main 4 | - beta/* 5 | 6 | name: 0.12$(Rev:.r) 7 | 8 | variables: 9 | skipDecorator: true 10 | framework: dotnet 11 | checkmarxName: Lime 12 | 13 | resources: 14 | repositories: 15 | - repository: templates 16 | type: git 17 | name: Operações/template-take-blip 18 | ref: refs/tags/stable 19 | 20 | extends: 21 | template: template-pipeline.yml@templates 22 | parameters: 23 | skipSast: true 24 | sastFilter: "!**/**, src/*" 25 | 26 | skipSonarBranch: true 27 | solution: "src/Lime.sln" 28 | packagename: lime-csharp 29 | type: dotnet 30 | to: nuget 31 | nugetServiceConnection: Nuget.org Take 32 | includeSymbols: true 33 | csprojToPack: 34 | - "Lime.Protocol.csproj" 35 | - "Lime.Messaging.csproj" 36 | - "Lime.Transport.Tcp.csproj" 37 | - "Lime.Transport.Redis.csproj" 38 | - "Lime.Transport.WebSocket.csproj" 39 | - "Lime.Transport.AspNetCore.csproj" 40 | skipTestToNuget: true 41 | testProjects: | 42 | src/Lime.Protocol.UnitTests/Lime.Protocol.UnitTests.csproj 43 | src/Lime.Transport.Tcp.UnitTests/Lime.Transport.Tcp.UnitTests.csproj 44 | src/Lime.Transport.WebSocket.UnitTests/Lime.Transport.WebSocket.UnitTests.csproj -------------------------------------------------------------------------------- /src/.idea/.idea.Lime/.idea/.name: -------------------------------------------------------------------------------- 1 | Lime -------------------------------------------------------------------------------- /src/.idea/.idea.Lime/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/.idea/.idea.Lime/.idea/projectSettingsUpdater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /src/.idea/.idea.Lime/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/Lime.Sample.Server/bin/Debug/netcoreapp3.0/Lime.Sample.Server.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/Lime.Sample.Server", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /src/Lime.Benchmarks/Lime.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Lime.Benchmarks/PipeTcpTransportBenchmark.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BenchmarkDotNet.Attributes; 3 | using Lime.Protocol.Network; 4 | using Lime.Protocol.Server; 5 | using Lime.Transport.Tcp; 6 | 7 | namespace Lime.Benchmarks 8 | { 9 | [CoreJob] 10 | [MemoryDiagnoser] 11 | public class PipeTcpTransportBenchmark : TransportBenchmarkBase 12 | { 13 | protected override Uri CreateUri() 14 | { 15 | return new Uri("net.tcp://localhost:55322"); 16 | } 17 | 18 | protected override ITransport CreateClientTransport() 19 | { 20 | return new PipeTcpTransport(EnvelopeSerializer, null); 21 | } 22 | 23 | protected override ITransportListener CreateTransportListener() 24 | { 25 | return new PipeTcpTransportListener(Uri, null, EnvelopeSerializer); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Benchmarks/PipeWebsocketTransportBenchmark.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using Lime.Messaging; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Network; 5 | using Lime.Protocol.Serialization; 6 | using Lime.Protocol.Serialization.Newtonsoft; 7 | using Lime.Protocol.Server; 8 | using Lime.Protocol.UnitTests; 9 | using Lime.Transport.WebSocket; 10 | using System; 11 | using System.Threading; 12 | using System.Threading.Tasks; 13 | 14 | namespace Lime.Benchmarks 15 | { 16 | [CoreJob] 17 | [MemoryDiagnoser] 18 | public class PipeWebSocketTransportBenchmark : TransportBenchmarkBase 19 | { 20 | protected override Uri CreateUri() 21 | { 22 | return new Uri("ws://localhost:8082"); 23 | } 24 | 25 | protected override ITransport CreateClientTransport() 26 | { 27 | return new PipeClientWebSocketTransport(EnvelopeSerializer); 28 | } 29 | 30 | protected override ITransportListener CreateTransportListener() 31 | { 32 | return new PipeWebSocketTransportListener(new[] { Uri }, EnvelopeSerializer); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Lime.Benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using System; 3 | 4 | namespace Lime.Benchmarks 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | //var summary = BenchmarkRunner.Run(); 11 | BenchmarkRunner.Run(); 12 | BenchmarkRunner.Run(); 13 | BenchmarkRunner.Run(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Lime.Benchmarks/TcpTransportBenchmark.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BenchmarkDotNet.Attributes; 3 | using Lime.Protocol.Network; 4 | using Lime.Protocol.Server; 5 | using Lime.Transport.Tcp; 6 | 7 | namespace Lime.Benchmarks 8 | { 9 | [CoreJob] 10 | [MemoryDiagnoser] 11 | public class TcpTransportBenchmark : TransportBenchmarkBase 12 | { 13 | protected override Uri CreateUri() 14 | { 15 | return new Uri("net.tcp://localhost:55321"); 16 | } 17 | 18 | protected override ITransport CreateClientTransport() 19 | { 20 | return new TcpTransport(EnvelopeSerializer, null); 21 | } 22 | 23 | protected override ITransportListener CreateTransportListener() 24 | { 25 | return new TcpTransportListener(Uri, null, EnvelopeSerializer); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Benchmarks/WebsocketTransportBenchmark.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using Lime.Messaging; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Network; 5 | using Lime.Protocol.Serialization; 6 | using Lime.Protocol.Serialization.Newtonsoft; 7 | using Lime.Protocol.Server; 8 | using Lime.Protocol.UnitTests; 9 | using Lime.Transport.WebSocket; 10 | using System; 11 | using System.Threading; 12 | using System.Threading.Tasks; 13 | 14 | namespace Lime.Benchmarks 15 | { 16 | [CoreJob] 17 | [MemoryDiagnoser] 18 | public class WebSocketTransportBenchmark : TransportBenchmarkBase 19 | { 20 | protected override Uri CreateUri() 21 | { 22 | return new Uri("ws://localhost:8081"); 23 | } 24 | 25 | protected override ITransport CreateClientTransport() 26 | { 27 | return new ClientWebSocketTransport(EnvelopeSerializer); 28 | } 29 | 30 | protected override ITransportListener CreateTransportListener() 31 | { 32 | return new WebSocketTransportListener(new[] { Uri }, EnvelopeSerializer); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/ActionBase.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lime.Cli.Actions 7 | { 8 | public abstract class ActionBase : IAction 9 | { 10 | public Type OptionsType => typeof(TOptions); 11 | 12 | Task IAction.ExecuteAsync(object options, IEstablishedChannel channel, CancellationToken cancellationToken) 13 | { 14 | return ExecuteAsync((TOptions)options, channel, cancellationToken); 15 | } 16 | 17 | protected abstract Task ExecuteAsync(TOptions options, IEstablishedChannel channel, CancellationToken cancellationToken); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/CreateAccountAction.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Messaging.Resources; 4 | using Lime.Protocol; 5 | using Lime.Protocol.Network; 6 | 7 | namespace Lime.Cli.Actions 8 | { 9 | public class CreateAccountAction : ActionBase 10 | { 11 | protected override Task ExecuteAsync(CreateAccountOptions options, IEstablishedChannel channel, CancellationToken cancellationToken) 12 | { 13 | var identity = Identity.Parse(options.Identity); 14 | 15 | return channel.SetResourceAsync( 16 | new LimeUri($"lime://{identity}{UriTemplates.ACCOUNT}"), 17 | new Account() 18 | { 19 | Identity = identity, 20 | Password = options.Password.ToBase64(), 21 | FullName = options.Name 22 | }, 23 | cancellationToken); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/CreateAccountOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace Lime.Cli.Actions 4 | { 5 | [Verb("create-account", HelpText = "Creates an account in the server")] 6 | public class CreateAccountOptions 7 | { 8 | [Option(HelpText = "The account identity", Required = true)] 9 | public string Identity { get; set; } 10 | 11 | [Option(HelpText = "The account password", Required = true)] 12 | public string Password { get; set; } 13 | 14 | [Option(HelpText = "The account name")] 15 | public string Name { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/IAction.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lime.Cli.Actions 7 | { 8 | public interface IAction 9 | { 10 | Type OptionsType { get; } 11 | 12 | Task ExecuteAsync(object options, IEstablishedChannel channel, CancellationToken cancellationToken); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/ProcessCommandOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | using Lime.Protocol; 3 | 4 | namespace Lime.Cli.Actions 5 | { 6 | [Verb("process-command", HelpText = "Process a command to a node and validates the response")] 7 | public class ProcessCommandOptions : SendCommandOptions 8 | { 9 | [Option(HelpText = "The expected command status", Default = CommandStatus.Success)] 10 | public CommandStatus ExpectedStatus { get; set; } 11 | 12 | [Option(HelpText = "A regex with the expected command resource in case of 'get' method")] 13 | public string ExpectedResource { get; set; } 14 | 15 | [Option(HelpText = "The timeout for awaiting the response, in seconds", Default = 30)] 16 | public int Timeout { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/ReceiveMessageOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Cli.Actions 2 | { 3 | public class ReceiveMessageOptions 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/SendCommandAction.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Serialization; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Cli.Actions 8 | { 9 | public class SendCommandAction : ActionBase 10 | { 11 | private readonly IDocumentSerializer _documentSerializer; 12 | 13 | public SendCommandAction(IDocumentSerializer documentSerializer) 14 | { 15 | _documentSerializer = documentSerializer; 16 | } 17 | 18 | protected override Task ExecuteAsync(SendCommandOptions options, IEstablishedChannel channel, CancellationToken cancellationToken) 19 | { 20 | var resource = _documentSerializer.Deserialize(options.JoinedResource, options.Type); 21 | 22 | return channel.SendCommandAsync( 23 | new Command(options.Id ?? EnvelopeId.NewId()) 24 | { 25 | From = options.From, 26 | To = options.To, 27 | Method = options.Method, 28 | Uri = new LimeUri(options.Uri), 29 | Resource = resource 30 | }, 31 | cancellationToken); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/SendCommandOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | using Lime.Protocol; 3 | using System.Collections.Generic; 4 | 5 | namespace Lime.Cli.Actions 6 | { 7 | [Verb("send-command", HelpText = "Sends a command to a node")] 8 | public class SendCommandOptions : SendEnvelopeOptions 9 | { 10 | [Option(HelpText = "The command URI", Required = true)] 11 | public string Uri { get; set; } 12 | 13 | [Option(HelpText = "The command method", Default = CommandMethod.Get)] 14 | public CommandMethod Method { get; set; } 15 | 16 | [Option(HelpText = "The command resource", Separator = ' ')] 17 | public IEnumerable Resource { get; set; } 18 | 19 | public string JoinedResource => Resource != null ? string.Join(' ', Resource) : null; 20 | } 21 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/SendEnvelopeOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace Lime.Cli.Actions 4 | { 5 | public class SendEnvelopeOptions 6 | { 7 | [Option(HelpText = "The envelope id")] 8 | public string Id { get; set; } 9 | 10 | [Option(HelpText = "The envelope sender node")] 11 | public string From { get; set; } 12 | 13 | [Option(HelpText = "The envelope destination node")] 14 | public string To { get; set; } 15 | 16 | [Option(HelpText = "The envelope destination node", Default = "text/plain")] 17 | public string Type { get; set; } 18 | 19 | [Option(HelpText = "The envelope metadata")] 20 | public string Metadata { get; set; } 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/SendMessageAction.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Serialization; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Cli.Actions 8 | { 9 | public class SendMessageAction : ActionBase 10 | { 11 | private readonly IDocumentSerializer _documentSerializer; 12 | 13 | public SendMessageAction(IDocumentSerializer documentSerializer) 14 | { 15 | _documentSerializer = documentSerializer; 16 | } 17 | 18 | protected override Task ExecuteAsync(SendMessageOptions options, IEstablishedChannel channel, CancellationToken cancellationToken) 19 | { 20 | var content = _documentSerializer.Deserialize(options.JoinedContent, options.Type); 21 | 22 | return channel.SendMessageAsync( 23 | new Message(options.Id) 24 | { 25 | From = options.From, 26 | To = options.To, 27 | Content = content 28 | }, 29 | cancellationToken); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Lime.Cli/Actions/SendMessageOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | using System.Collections.Generic; 3 | 4 | namespace Lime.Cli.Actions 5 | { 6 | [Verb("send-message", HelpText = "Sends a message to a node")] 7 | public class SendMessageOptions : SendEnvelopeOptions 8 | { 9 | [Option(HelpText = "The message content", Required = true, Separator = ' ')] 10 | public IEnumerable Content { get; set; } 11 | 12 | public string JoinedContent => string.Join(' ', Content); 13 | } 14 | } -------------------------------------------------------------------------------- /src/Lime.Cli/ConnectionInformation.cs: -------------------------------------------------------------------------------- 1 | using Lime.Messaging.Resources; 2 | using Lime.Protocol; 3 | using Lime.Protocol.Security; 4 | using System; 5 | 6 | namespace Lime.Cli 7 | { 8 | public class ConnectionInformation 9 | { 10 | public Identity Identity { get; set; } 11 | 12 | public string Password { get; set; } 13 | 14 | public string Key { get; set; } 15 | 16 | /// 17 | /// Token to be used with External Authentication 18 | /// 19 | public string Token { get; set; } 20 | 21 | /// 22 | /// Issuer to be used with External Authentication. Defaults to accounts.blip.ai 23 | /// 24 | public string Issuer { get; set; } 25 | 26 | public string Instance { get; set; } 27 | 28 | public Uri ServerUri { get; set; } 29 | 30 | public Presence Presence { get; set; } 31 | 32 | public Receipt Receipt { get; set; } 33 | 34 | /// 35 | /// Thumbprint for the X509 Certificate to use as Transport Authentication 36 | /// 37 | public string CertificateThumbprint { get; set; } 38 | 39 | /// 40 | /// Domain role to use as Transport Authentication 41 | /// 42 | public DomainRole DomainRole { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Lime.Cli/IOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Cli 2 | { 3 | public interface IOptions : IConnectionOptions 4 | { 5 | int Timeout { get; } 6 | 7 | string Action { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Lime.Cli.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | 8.0 7 | LIME 8 | LIME Protocol 9 | andreb 10 | lime 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | PreserveNewest 28 | 29 | 30 | PreserveNewest 31 | 32 | 33 | PreserveNewest 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/Lime.Cli/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Lime.Cli": { 4 | "commandName": "Project", 5 | "commandLineArgs": "--identity andreb@msging.net --password 123456 --uri net.tcp://tcp.msging.net:443 --presence.status available --presence.routingrule identity --action process-command --action.uri /ping --action.to postmaster@msging.net --action.method get --action.expectedresource {}" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Lime.Cli/Readme.md: -------------------------------------------------------------------------------- 1 | # LIME command line interface 2 | 3 | 4 | ## Interactive (default) 5 | 6 | ``` 7 | lime --identity myuser@msging.net --password mypassword --instance home --uri net.tcp://tcp.msging.net:443 --presence.status available --presence.routingrule identity --verbose 8 | 9 | Welcome to LIME 10 | Successfully connected to server 'postmaster@msging.net/#az-iris1' 11 | Send 'help' if you are in trouble 12 | > send-message --to otheruser@msging.net --type text/plain --content Hello 13 | ``` 14 | 15 | ## Non-interactive 16 | 17 | ``` 18 | lime --identity myuser@msging.net --password mypassword --instance home --uri net.tcp://tcp.msging.net:443 --action send-message --action.to otheruser@msging.net --action.type text/plain --action.content Hello 19 | ``` 20 | -------------------------------------------------------------------------------- /src/Lime.Cli/VERIFICATION.txt: -------------------------------------------------------------------------------- 1 | VERIFICATION 2 | Verification is intended to assist the Chocolatey moderators and community 3 | in verifying that this package's contents are trustworthy. 4 | 5 | This package is published by the Take and BLiP, the LIME protocol maintainers itself (https://limeprotocol.org/about.html) 6 | The binaries are identical to other package types published by the project. -------------------------------------------------------------------------------- /src/Lime.Cli/connection.json: -------------------------------------------------------------------------------- 1 | { 2 | "identity": "andreb@msging.net", 3 | "password": "123456", 4 | "serverUri": "net.tcp://msging.net:55321", 5 | "presence": { 6 | "status": "available", 7 | "routingRule": "identity" 8 | }, 9 | "receipt": { 10 | "events": ["received", "consumed"] 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Cli/lime-cli.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | lime-cli 5 | LIME command line interface 6 | 0.1.0 7 | Helper CLI to connect to LIME servers and send envelopes 8 | Helper CLI to connect to LIME servers and send envelopes 9 | take,andreb 10 | https://limeprotocol.org 11 | https://github.com/takenet/lime-csharp/blob/master/LICENSE 12 | https://github.com/takenet/lime-csharp 13 | https://github.com/takenet/lime-csharp/tree/master/src/Lime.Cli 14 | 15 | * 0.1.0 - First CLI release, with basic support for sending messages, notifications and sending/processing commands. 16 | 17 | lime cli messaging blip 18 | 19 | -------------------------------------------------------------------------------- /src/Lime.Cli/publish.bat: -------------------------------------------------------------------------------- 1 | dotnet publish --self-contained --runtime win-x64 -c Release 2 | cd .\bin\Release\netcoreapp2.1\win-x64\publish\ 3 | choco pack 4 | choco push --api-key [CHOCOLATEY-API-KEY] -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.Properties; 2 | using System.Windows; 3 | 4 | namespace Lime.Client.TestConsole 5 | { 6 | /// 7 | /// Interaction logic for App.xaml 8 | /// 9 | public partial class App : Application 10 | { 11 | private void Application_Exit(object sender, ExitEventArgs e) 12 | { 13 | Settings.Default.Save(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Converters/Converters.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Converters/IsErrorToBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Data; 9 | using System.Windows.Media; 10 | 11 | namespace Lime.Client.TestConsole.Converters 12 | { 13 | public class IsErrorToBrushConverter : IMultiValueConverter 14 | { 15 | #region IValueConverter Members 16 | 17 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) 18 | { 19 | var isError = values[0]; 20 | var darkMode = values[1]; 21 | 22 | if (isError is bool && 23 | (bool)isError) 24 | { 25 | return new SolidColorBrush(Colors.Red); 26 | } 27 | 28 | if (darkMode is Style) 29 | { 30 | return new SolidColorBrush(Colors.White); 31 | } 32 | 33 | return new SolidColorBrush(Colors.Black); 34 | } 35 | 36 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | 41 | #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Converters/IsRawToBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Data; 9 | using System.Windows.Media; 10 | 11 | namespace Lime.Client.TestConsole.Converters 12 | { 13 | public class IsRawToBrushConverter : IMultiValueConverter 14 | { 15 | #region IValueConverter Members 16 | 17 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) 18 | { 19 | var isRaw = values[0]; 20 | var darkMode = values[1]; 21 | 22 | if (isRaw is bool && (bool)isRaw) 23 | { 24 | return new SolidColorBrush(Colors.Red); 25 | } 26 | 27 | if (darkMode is Style) 28 | { 29 | return new SolidColorBrush(Colors.White); 30 | } 31 | 32 | return new SolidColorBrush(Colors.Black); 33 | } 34 | 35 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | 40 | #endregion 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Converters/ToStringConverter.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Data; 8 | using System.Windows.Media; 9 | 10 | namespace Lime.Client.TestConsole.Converters 11 | { 12 | public class ToStringConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | 16 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 17 | { 18 | if (value!= null) 19 | { 20 | return value.ToString(); 21 | } 22 | 23 | return string.Empty; 24 | } 25 | 26 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/DesignData/EnvelopeDesignData.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/DesignData/MainDesignData.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/CloseTransportMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.ViewModels; 2 | using Lime.Protocol; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Lime.Client.TestConsole.Macros 10 | { 11 | [Macro(Name = "Close transport on finished / failed", Category = "Session", IsActiveByDefault = true)] 12 | public class CloseTransportMacro : IMacro 13 | { 14 | #region IMacro Members 15 | 16 | public async Task ProcessAsync(EnvelopeViewModel envelopeViewModel, SessionViewModel sessionViewModel) 17 | { 18 | if (envelopeViewModel == null) 19 | { 20 | throw new ArgumentNullException("envelopeViewModel"); 21 | } 22 | 23 | if (sessionViewModel == null) 24 | { 25 | throw new ArgumentNullException("sessionViewModel"); 26 | } 27 | 28 | var session = envelopeViewModel.Envelope as Session; 29 | 30 | if (session != null && 31 | new[] { SessionState.Finished, SessionState.Failed }.Contains(session.State) && 32 | sessionViewModel.CloseTransportCommand.CanExecute(null)) 33 | { 34 | await sessionViewModel.CloseTransportCommand.ExecuteAsync(null); 35 | } 36 | } 37 | 38 | #endregion 39 | } 40 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/IMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.ViewModels; 2 | using Lime.Protocol.Network; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Client.TestConsole.Macros 9 | { 10 | public interface IMacro 11 | { 12 | Task ProcessAsync(EnvelopeViewModel envelopeViewModel, SessionViewModel sessionViewModel); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/MacroAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | [AttributeUsage(AttributeTargets.Class)] 6 | public class MacroAttribute : Attribute 7 | { 8 | public string Name { get; set; } 9 | 10 | public string Category { get; set; } 11 | 12 | public bool IsActiveByDefault { get; set; } 13 | 14 | public int Order { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingExternalMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | 6 | [Macro(Name = "Send authenticating external", Category = "Session", IsActiveByDefault = false, Order = 1)] 7 | public class SendAuthenticatingExternalMacro : SendAuthenticatingMacroBase 8 | { 9 | protected override string TemplateName => "Authenticating external"; 10 | 11 | protected override AuthenticationScheme Scheme => AuthenticationScheme.External; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingGuestMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | [Macro(Name = "Send authenticating guest", Category = "Session", IsActiveByDefault = false, Order = 1)] 6 | public class SendAuthenticatingGuestMacro : SendAuthenticatingMacroBase 7 | { 8 | protected override string TemplateName => "Authenticating guest"; 9 | 10 | protected override AuthenticationScheme Scheme => AuthenticationScheme.Guest; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingKeyMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | [Macro(Name = "Send authenticating key", Category = "Session", IsActiveByDefault = false, Order = 1)] 6 | public class SendAuthenticatingKeyMacro : SendAuthenticatingMacroBase 7 | { 8 | protected override string TemplateName => "Authenticating key"; 9 | 10 | protected override AuthenticationScheme Scheme => AuthenticationScheme.Key; 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingMacroBase.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Lime.Client.TestConsole.ViewModels; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Security; 5 | 6 | namespace Lime.Client.TestConsole.Macros 7 | { 8 | public abstract class SendAuthenticatingMacroBase : SendTemplateMacroBase 9 | { 10 | protected override bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel) 11 | { 12 | var session = envelopeViewModel.Envelope as Session; 13 | if (session != null && 14 | session.State == SessionState.Authenticating && 15 | session.SchemeOptions != null && 16 | session.SchemeOptions.Contains(Scheme)) 17 | { 18 | return true; 19 | } 20 | 21 | return false; 22 | } 23 | 24 | protected abstract AuthenticationScheme Scheme { get; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingPlainMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | [Macro(Name = "Send authenticating plain", Category = "Session", IsActiveByDefault = false, Order = 1)] 6 | public class SendAuthenticatingPlainMacro : SendAuthenticatingMacroBase 7 | { 8 | protected override string TemplateName => "Authenticating plain"; 9 | 10 | protected override AuthenticationScheme Scheme => AuthenticationScheme.Plain; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendAuthenticatingTransportMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | 3 | namespace Lime.Client.TestConsole.Macros 4 | { 5 | [Macro(Name = "Send authenticating transport", Category = "Session", IsActiveByDefault = false, Order = 1)] 6 | public class SendAuthenticatingTransportMacro : SendAuthenticatingMacroBase 7 | { 8 | protected override string TemplateName => "Authenticating transport"; 9 | 10 | protected override AuthenticationScheme Scheme => AuthenticationScheme.Transport; 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendNegotiatingNoneNoneMacro.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Lime.Client.TestConsole.ViewModels; 3 | using Lime.Protocol; 4 | 5 | namespace Lime.Client.TestConsole.Macros 6 | { 7 | [Macro(Name = "Send negotiating none/none", Category = "Session", IsActiveByDefault = false, Order = 1)] 8 | public class SendNegotiatingNoneNoneMacro : SendTemplateMacroBase 9 | { 10 | protected override bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel) 11 | { 12 | var session = envelopeViewModel.Envelope as Session; 13 | if (session != null && 14 | session.State == SessionState.Negotiating && 15 | session.CompressionOptions != null && 16 | session.CompressionOptions.Contains(SessionCompression.None) && 17 | session.EncryptionOptions != null && 18 | session.EncryptionOptions.Contains(SessionEncryption.None)) 19 | { 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | protected override string TemplateName => "Negotiating none/none"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendNegotiatingNoneTlsMacro.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Lime.Client.TestConsole.ViewModels; 3 | using Lime.Protocol; 4 | 5 | namespace Lime.Client.TestConsole.Macros 6 | { 7 | [Macro(Name = "Send negotiating none/tls", Category = "Session", IsActiveByDefault = false, Order = 1)] 8 | public class SendNegotiatingNoneTlsMacro : SendTemplateMacroBase 9 | { 10 | protected override bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel) 11 | { 12 | var session = envelopeViewModel.Envelope as Session; 13 | if (session != null && 14 | session.State == SessionState.Negotiating && 15 | session.CompressionOptions != null && 16 | session.CompressionOptions.Contains(SessionCompression.None) && 17 | session.EncryptionOptions != null && 18 | session.EncryptionOptions.Contains(SessionEncryption.TLS)) 19 | { 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | protected override string TemplateName => "Negotiating none/tls"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendSetPresenceAvailableIdentityMacro.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Lime.Client.TestConsole.ViewModels; 7 | using Lime.Protocol; 8 | 9 | namespace Lime.Client.TestConsole.Macros 10 | { 11 | [Macro(Name = "Send set presence available identity", Category = "Command", IsActiveByDefault = false)] 12 | public class SendSetPresenceAvailableIdentityMacro : SendTemplateMacroBase 13 | { 14 | protected override bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel) 15 | { 16 | var session = envelopeViewModel.Envelope as Session; 17 | if (session != null && 18 | session.State == SessionState.Established) 19 | { 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | protected override string TemplateName => "Set presence available identity"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendSetPresenceAvailableMacro.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.ViewModels; 2 | using Lime.Protocol; 3 | 4 | namespace Lime.Client.TestConsole.Macros 5 | { 6 | [Macro(Name = "Send set presence available", Category = "Command", IsActiveByDefault = false)] 7 | public class SendSetPresenceAvailableMacro : SendTemplateMacroBase 8 | { 9 | protected override bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel) 10 | { 11 | var session = envelopeViewModel.Envelope as Session; 12 | if (session != null && 13 | session.State == SessionState.Established) 14 | { 15 | return true; 16 | } 17 | 18 | return false; 19 | } 20 | 21 | protected override string TemplateName => "Set presence available"; 22 | } 23 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SendTemplateMacroBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Lime.Client.TestConsole.ViewModels; 5 | 6 | namespace Lime.Client.TestConsole.Macros 7 | { 8 | public abstract class SendTemplateMacroBase : IMacro 9 | { 10 | public async Task ProcessAsync(EnvelopeViewModel envelopeViewModel, SessionViewModel sessionViewModel) 11 | { 12 | if (envelopeViewModel == null) throw new ArgumentNullException(nameof(envelopeViewModel)); 13 | if (sessionViewModel == null) throw new ArgumentNullException(nameof(sessionViewModel)); 14 | 15 | if (ShouldSendTemplate(envelopeViewModel)) 16 | { 17 | var template = sessionViewModel.Templates.FirstOrDefault(t => t.Name.Equals(TemplateName, StringComparison.OrdinalIgnoreCase)); 18 | if (template != null) 19 | { 20 | if (sessionViewModel.SendCommand.CanExecute(null)) 21 | { 22 | await sessionViewModel.SendCommand.ExecuteAsync(template.JsonTemplate); 23 | } 24 | } 25 | } 26 | } 27 | 28 | protected abstract bool ShouldSendTemplate(EnvelopeViewModel envelopeViewModel); 29 | 30 | 31 | protected abstract string TemplateName { get; } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Macros/SetNotificationEvent.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.ViewModels; 2 | using Lime.Protocol; 3 | using System; 4 | using System.Threading.Tasks; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Lime.Client.TestConsole.Macros 10 | { 11 | [Macro(Name = "Set notification event", Category = "Notification", IsActiveByDefault = true)] 12 | public class SetNotificationEvent : IMacro 13 | { 14 | #region IMacro Members 15 | 16 | public Task ProcessAsync(EnvelopeViewModel envelopeViewModel, SessionViewModel sessionViewModel) 17 | { 18 | if (envelopeViewModel == null) 19 | { 20 | throw new ArgumentNullException("envelopeViewModel"); 21 | } 22 | 23 | if (sessionViewModel == null) 24 | { 25 | throw new ArgumentNullException("sessionViewModel"); 26 | } 27 | 28 | var notification = envelopeViewModel.Envelope as Notification; 29 | 30 | if (notification != null) 31 | { 32 | sessionViewModel.LastNotificationEvent = notification.Event; 33 | } 34 | 35 | return Task.FromResult(null); 36 | } 37 | 38 | #endregion 39 | } 40 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Lime.Client.TestConsole 4 | { 5 | /// 6 | /// Interaction logic for MainWindow.xaml 7 | /// 8 | public partial class MainWindow : Window 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ValidationRules/JsonEnvelopeValidationRule.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.TestConsole.ViewModels; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Controls; 5 | 6 | namespace Lime.Client.TestConsole.ValidationRules 7 | { 8 | public class JsonEnvelopeValidationRule : ValidationRule 9 | { 10 | public override ValidationResult Validate(object value, CultureInfo cultureInfo) 11 | { 12 | try 13 | { 14 | var inputJson = value?.ToString(); 15 | EnvelopeViewModel.Parse(value.ToString()); 16 | } 17 | catch (Exception exception) 18 | { 19 | return new ValidationResult(false, exception.Message); 20 | } 21 | 22 | return new ValidationResult(true, null); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Variables.txt: -------------------------------------------------------------------------------- 1 | from andre@limeprotocol.org 2 | to %from 3 | password MTIzNDU2 4 | text Hello world! 5 | groupIdentity chat@groups.limeprotocol.org 6 | groupName Lime Chat 7 | messageId %newGuid 8 | commandId %newGuid 9 | webLinkTarget blank -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ViewModels/ProfileViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using System.Collections.Generic; 3 | 4 | namespace Lime.Client.TestConsole.ViewModels 5 | { 6 | public class ProfileViewModel : ObservableRecipient 7 | { 8 | private string _name; 9 | 10 | public string Name 11 | { 12 | get { return _name; } 13 | set 14 | { 15 | _name = value; 16 | OnPropertyChanged(nameof(Name)); 17 | } 18 | } 19 | 20 | private IDictionary _jsonValues; 21 | 22 | public IDictionary JsonValues 23 | { 24 | get { return _jsonValues; } 25 | set 26 | { 27 | _jsonValues = value; 28 | OnPropertyChanged(nameof(JsonValues)); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ViewModels/StatusMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using System; 3 | 4 | namespace Lime.Client.TestConsole.ViewModels 5 | { 6 | public class StatusMessageViewModel : ObservableRecipient 7 | { 8 | private DateTimeOffset _timestamp; 9 | 10 | public DateTimeOffset Timestamp 11 | { 12 | get { return _timestamp; } 13 | set 14 | { 15 | _timestamp = value; 16 | OnPropertyChanged(nameof(Timestamp)); 17 | OnPropertyChanged(nameof(TimestampFormat)); 18 | } 19 | } 20 | 21 | public string TimestampFormat 22 | { 23 | get { return _timestamp.ToString("yyyy-MM-ddTHH:mm:ss.fff zzz"); } 24 | } 25 | 26 | private bool _isError; 27 | 28 | public bool IsError 29 | { 30 | get { return _isError; } 31 | set 32 | { 33 | _isError = value; 34 | OnPropertyChanged(nameof(IsError)); 35 | } 36 | } 37 | 38 | private string _message; 39 | 40 | public string Message 41 | { 42 | get { return _message; } 43 | set 44 | { 45 | _message = value; 46 | OnPropertyChanged(nameof(Message)); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ViewModels/TemplateViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | 3 | namespace Lime.Client.TestConsole.ViewModels 4 | { 5 | public class TemplateViewModel : ObservableRecipient 6 | { 7 | private string _name; 8 | 9 | public string Name 10 | { 11 | get { return _name; } 12 | set 13 | { 14 | _name = value; 15 | OnPropertyChanged(nameof(Name)); 16 | } 17 | } 18 | 19 | private string _category; 20 | 21 | public string Category 22 | { 23 | get { return _category; } 24 | set 25 | { 26 | _category = value; 27 | OnPropertyChanged(nameof(Category)); 28 | } 29 | } 30 | 31 | 32 | private string _jsonTemplate; 33 | public string JsonTemplate 34 | { 35 | get { return _jsonTemplate; } 36 | set 37 | { 38 | _jsonTemplate = value; 39 | OnPropertyChanged(nameof(JsonTemplate)); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ViewModels/UIHelper.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | 4 | namespace Lime.Client.TestConsole.ViewModels 5 | { 6 | public static class UIHelper 7 | { 8 | private static bool? isInDesignMode; 9 | 10 | // 11 | // Summary: 12 | // Determines whether the current code is executed in a design time environment 13 | // such as Visual Studio or Blend. 14 | public static bool IsInDesignMode 15 | { 16 | get 17 | { 18 | if (!isInDesignMode.HasValue) 19 | { 20 | isInDesignMode = DesignerProperties.GetIsInDesignMode(new DependencyObject()); 21 | } 22 | 23 | return isInDesignMode.Value; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/ViewModels/VariableViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | 3 | namespace Lime.Client.TestConsole.ViewModels 4 | { 5 | public class VariableViewModel : ObservableRecipient 6 | { 7 | 8 | private string _name; 9 | 10 | public string Name 11 | { 12 | get { return _name; } 13 | set 14 | { 15 | _name = value; 16 | OnPropertyChanged(nameof(Name)); 17 | } 18 | } 19 | 20 | 21 | private string _value; 22 | 23 | public string Value 24 | { 25 | get { return _value; } 26 | set 27 | { 28 | _value = value; 29 | OnPropertyChanged(nameof(Value)); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Views/EnvelopeView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/Views/EnvelopeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.TestConsole.Views 17 | { 18 | /// 19 | /// Interaction logic for EnvelopeView.xaml 20 | /// 21 | public partial class EnvelopeView : UserControl 22 | { 23 | public EnvelopeView() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.TestConsole/lime.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.TestConsole/lime.ico -------------------------------------------------------------------------------- /src/Lime.Client.Windows/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.Windows.Properties; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | 10 | namespace Lime.Client.Windows 11 | { 12 | /// 13 | /// Interaction logic for App.xaml 14 | /// 15 | public partial class App : Application 16 | { 17 | public App() 18 | { 19 | 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/ConversationWindow.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Converters/BooleanToBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Data; 7 | using System.Windows.Media; 8 | 9 | namespace Lime.Client.Windows.Converters 10 | { 11 | public class BooleanToBrushConverter : IValueConverter 12 | { 13 | #region IValueConverter Members 14 | 15 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 16 | { 17 | if (value is bool) 18 | { 19 | if ((bool)value) 20 | { 21 | return new SolidColorBrush(Colors.LightGray); 22 | } 23 | } 24 | 25 | return new SolidColorBrush(Colors.Transparent); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Converters/BooleanToTextDecorationConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Data; 8 | using System.Windows.Media; 9 | 10 | namespace Lime.Client.Windows.Converters 11 | { 12 | public class BooleanToTextDecorationConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | 16 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 17 | { 18 | if (value is bool) 19 | { 20 | if (!(bool)value) 21 | { 22 | return TextDecorations.Strikethrough; 23 | } 24 | } 25 | 26 | return null; 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Converters/BooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Data; 8 | using System.Windows.Media; 9 | 10 | namespace Lime.Client.Windows.Converters 11 | { 12 | public class BooleanToVisibilityConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | 16 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 17 | { 18 | if (value is bool) 19 | { 20 | if (!(bool)value) 21 | { 22 | return Visibility.Collapsed; 23 | } 24 | } 25 | 26 | return Visibility.Visible; 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Converters/Converters.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Converters/DataOperationToBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Data; 8 | using System.Windows.Media; 9 | 10 | namespace Lime.Client.Windows.Converters 11 | { 12 | public class DataOperationToBrushConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | 16 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 17 | { 18 | if (value is DataOperation) 19 | { 20 | if (((DataOperation)value) == DataOperation.Receive) 21 | { 22 | return new SolidColorBrush(Colors.LightGray); 23 | } 24 | } 25 | 26 | return new SolidColorBrush(Colors.Transparent); 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/DesignData/ConversationDesignData.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/DesignData/LoginDesignData.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/DesignData/TraceDesignData.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Images/appbar.message.smiley.blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.Windows/Images/appbar.message.smiley.blue.ico -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Images/appbar.message.smiley.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.Windows/Images/appbar.message.smiley.ico -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Images/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.Windows/Images/placeholder.png -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Lime.Client.Windows_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.Windows/Lime.Client.Windows_TemporaryKey.pfx -------------------------------------------------------------------------------- /src/Lime.Client.Windows/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/OpenWindowMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Client.Windows 8 | { 9 | internal class OpenWindowMessage 10 | { 11 | private string _windowName; 12 | public string WindowName 13 | { 14 | get { return _windowName; } 15 | set 16 | { 17 | if (value == null) 18 | { 19 | throw new ArgumentNullException("value"); 20 | } 21 | _windowName = value; 22 | } 23 | } 24 | 25 | public object DataContext { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Pages/MessageItemTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using Lime.Client.Windows.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace Lime.Client.Windows.Pages 11 | { 12 | public class MessageItemTemplateSelector : DataTemplateSelector 13 | { 14 | public DataTemplate InputMessage { get; set; } 15 | 16 | public DataTemplate OutputMessage { get; set; } 17 | 18 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 19 | { 20 | var message = item as MessageViewModel; 21 | 22 | if (message != null) 23 | { 24 | if (message.Direction == MessageDirection.Input) 25 | { 26 | return InputMessage; 27 | } 28 | else 29 | { 30 | return OutputMessage; 31 | } 32 | } 33 | 34 | return base.SelectTemplate(item, container); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Pages/Roster.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows; 2 | using FirstFloor.ModernUI.Windows.Navigation; 3 | using Lime.Client.Windows.ViewModels; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | using System.Windows.Shapes; 17 | 18 | namespace Lime.Client.Windows.Pages 19 | { 20 | /// 21 | /// Interaction logic for Roster.xaml 22 | /// 23 | public partial class Roster : UserControl, IContent 24 | { 25 | public Roster() 26 | { 27 | InitializeComponent(); 28 | } 29 | 30 | #region IContent Members 31 | 32 | public void OnFragmentNavigation(FragmentNavigationEventArgs e) 33 | { 34 | } 35 | 36 | public void OnNavigatedFrom(NavigationEventArgs e) 37 | { 38 | 39 | } 40 | 41 | public void OnNavigatedTo(NavigationEventArgs e) 42 | { 43 | 44 | } 45 | 46 | public void OnNavigatingFrom(NavigatingCancelEventArgs e) 47 | { 48 | } 49 | 50 | #endregion 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Pages/RosterConversation.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Pages/RosterConversation.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.Windows.Pages 17 | { 18 | /// 19 | /// Interaction logic for RosterUserControl.xaml 20 | /// 21 | public partial class RosterUserControl : UserControl 22 | { 23 | public RosterUserControl() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Properties/Resources.en-US.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Client.Windows/Properties/Resources.en-US.Designer.cs -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Lime.Client.Windows.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/TraceWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/TraceWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.Windows 17 | { 18 | /// 19 | /// Interaction logic for TraceWindow.xaml 20 | /// 21 | public partial class TraceWindow : ModernWindow 22 | { 23 | public TraceWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/UserControls/ContactList.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.Windows.UserControls 17 | { 18 | /// 19 | /// Interaction logic for ContactList.xaml 20 | /// 21 | public partial class ContactList : UserControl 22 | { 23 | public ContactList() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/UserControls/PresenceComboBox.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.Windows.UserControls 17 | { 18 | /// 19 | /// Interaction logic for PresenceComboBox.xaml 20 | /// 21 | public partial class PresenceComboBox : UserControl 22 | { 23 | public PresenceComboBox() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/UserControls/RosterToolbar.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Lime.Client.Windows.UserControls 17 | { 18 | /// 19 | /// Interaction logic for RosterToolbar.xaml 20 | /// 21 | public partial class RosterToolbar : UserControl 22 | { 23 | public RosterToolbar() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Lime.Client.Windows/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/DeletedContent.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Messaging.Contents 5 | { 6 | /// 7 | /// Represents a message that has the content deleted 8 | /// 9 | [DataContract] 10 | public class DeletedContent : Document 11 | { 12 | public const string MIME_TYPE = "application/vnd.lime.deleted-content+json"; 13 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public DeletedContent() 19 | : base(MediaType) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/DocumentList.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Messaging.Contents 5 | { 6 | /// 7 | /// Defines a list of with a header. 8 | /// 9 | /// 10 | [DataContract] 11 | public class DocumentList : Document 12 | { 13 | public const string MIME_TYPE = "application/vnd.lime.list+json"; 14 | public const string HEADER_KEY = "header"; 15 | public const string ITEMS_KEY = "items"; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | public DocumentList() 21 | : base(MediaType.Parse(MIME_TYPE)) 22 | { 23 | 24 | } 25 | 26 | /// 27 | /// Gets or sets the list header document. 28 | /// 29 | /// 30 | /// The header. 31 | /// 32 | [DataMember(Name = HEADER_KEY)] 33 | public DocumentContainer Header { get; set; } 34 | 35 | /// 36 | /// Gets or sets the list items. 37 | /// 38 | /// 39 | /// The items. 40 | /// 41 | [DataMember(Name = ITEMS_KEY)] 42 | public DocumentContainer[] Items { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/External.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Messaging.Contents 5 | { 6 | /// 7 | /// Represents an external message. 8 | /// 9 | [DataContract] 10 | public class External : Document 11 | { 12 | public static readonly string MimeType = "application/vnd.lime.external+json"; 13 | public static readonly MediaType MediaType = MediaType.Parse(MimeType); 14 | 15 | public const string TYPE_KEY = "type"; 16 | public const string CONTENT_KEY = "content"; 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | public External() 21 | : base(MediaType) 22 | { 23 | } 24 | 25 | /// 26 | /// Gets or sets the type of external message content type. 27 | /// 28 | [DataMember(Name = TYPE_KEY)] 29 | public MediaType Type => Content?.GetMediaType(); 30 | 31 | /// 32 | /// Gets or sets the type of external message content. 33 | /// 34 | [DataMember(Name = CONTENT_KEY)] 35 | public Document Content { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/Item.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Lime.Protocol; 4 | 5 | namespace Lime.Messaging.Contents 6 | { 7 | /// 8 | /// Defines an item description. 9 | /// 10 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 11 | public class Item 12 | { 13 | public const string DESCRIPTION_KEY = "description"; 14 | public const string IMAGE_URI_KEY = "imageUri"; 15 | public const string IMAGE_TYPE_KEY = "imageType"; 16 | 17 | /// 18 | /// Gets or sets the product description. 19 | /// 20 | /// 21 | /// The description. 22 | /// 23 | [DataMember(Name = DESCRIPTION_KEY)] 24 | public string Description { get; set; } 25 | 26 | /// 27 | /// Gets or sets the image URI. 28 | /// 29 | /// 30 | /// The image URI. 31 | /// 32 | [DataMember(Name = IMAGE_URI_KEY)] 33 | public Uri ImageUri { get; set; } 34 | 35 | /// 36 | /// Gets or sets the type of the image. 37 | /// 38 | /// 39 | /// The type of the image. 40 | /// 41 | [DataMember(Name = IMAGE_TYPE_KEY)] 42 | public MediaType ImageType { get; set; } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/MessageDirection.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Messaging.Contents 4 | { 5 | [DataContract] 6 | public enum MessageDirection 7 | { 8 | /// 9 | /// The message was sent by the thread owner. 10 | /// 11 | [EnumMember(Value = "sent")] 12 | Sent, 13 | /// 14 | /// The message was received by the thread owner. 15 | /// 16 | [EnumMember(Value = "received")] 17 | Received 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/PaymentMethod.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Messaging.Contents 4 | { 5 | /// 6 | /// Defines a payment method. 7 | /// 8 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 9 | public class PaymentMethod 10 | { 11 | public const string NAME_KEY = "name"; 12 | public const string ACCOUNT_KEY = "account"; 13 | 14 | /// 15 | /// Gets or sets the payment method name. 16 | /// 17 | /// 18 | /// The name. 19 | /// 20 | [DataMember(Name = NAME_KEY)] 21 | public string Name { get; set; } 22 | 23 | /// 24 | /// Gets or sets the payment method account information of the seller. 25 | /// 26 | /// 27 | /// The account. 28 | /// 29 | [DataMember(Name = ACCOUNT_KEY)] 30 | public string Account { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Lime.Messaging/Contents/Redirect.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Messaging.Contents 5 | { 6 | /// 7 | /// Indicates to a node to redirect to another address in order to continue the current conversation. 8 | /// It is useful to handover the current conversation to another connected nodes. 9 | /// 10 | public class Redirect : Document 11 | { 12 | public const string MIME_TYPE = "application/vnd.lime.redirect+json"; 13 | public const string ADDRESS_KEY = "address"; 14 | public const string CONTEXT_KEY = "context"; 15 | 16 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | public Redirect() 22 | : base(MediaType) 23 | { 24 | } 25 | 26 | /// 27 | /// Gets or sets the redirect address. 28 | /// 29 | [DataMember(Name = ADDRESS_KEY)] 30 | public Node Address { get; set; } 31 | 32 | /// 33 | /// Gets or sets the state data to be forwarded to the redirect address in order to keep the conversation context. 34 | /// 35 | [DataMember(Name = CONTEXT_KEY)] 36 | public DocumentContainer Context { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Lime.Messaging/DocumentTypeResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Lime.Protocol.Serialization; 3 | 4 | namespace Lime.Messaging 5 | { 6 | public static class DocumentTypeResolverExtensions 7 | { 8 | /// 9 | /// Registers all documents in the Lime.Messaging assembly. 10 | /// 11 | /// 12 | /// 13 | public static IDocumentTypeResolver WithMessagingDocuments(this IDocumentTypeResolver documentTypeResolver) 14 | { 15 | documentTypeResolver.RegisterAssemblyDocuments(typeof(DocumentTypeResolverExtensions).GetTypeInfo().Assembly); 16 | return documentTypeResolver; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Lime.Messaging.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Common content types and resource for LIME messaging applications. 5 | Copyright � 2014 Curupira S/A 6 | Lime.Messaging 7 | takenet;andrebires 8 | netstandard2.0;net462 9 | Lime.Messaging 10 | Lime.Messaging 11 | lime 12 | http://limeprotocol.org 13 | 1.0.0 14 | true 15 | 1591 16 | 8.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Lime.Messaging/Resources/Ping.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using Lime.Protocol; 3 | 4 | namespace Lime.Messaging.Resources 5 | { 6 | /// 7 | /// Allows the nodes to test 8 | /// the network connectivity. 9 | /// 10 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 11 | public class Ping : Document 12 | { 13 | public const string MIME_TYPE = "application/vnd.lime.ping+json"; 14 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public Ping() 20 | : base(MediaType) 21 | { 22 | 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Lime.Messaging/Resources/Receipt.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using Lime.Protocol; 3 | 4 | namespace Lime.Messaging.Resources 5 | { 6 | /// 7 | /// Represents the events that should generate receipts (notifications) for the messages sent by the owner identity. 8 | /// 9 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 10 | public class Receipt : Document 11 | { 12 | public const string MIME_TYPE = "application/vnd.lime.receipt+json"; 13 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 14 | 15 | public const string EVENTS_KEY = "events"; 16 | public const string DELIVER_HOPS_KEY = "deliverHops"; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | public Receipt() 22 | : base(MediaType) 23 | { 24 | 25 | } 26 | 27 | /// 28 | /// Indicates which message events that the identity want to receive. 29 | /// 30 | [DataMember(Name = EVENTS_KEY)] 31 | public Event[] Events { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Lime.Protocol.ConsoleTests/Lime.Protocol.ConsoleTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | PreserveNewest 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Lime.Protocol.ConsoleTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TcpTransport": "net.tcp://localhost:55321", 3 | "PipeTcpTransport": "net.tcp://localhost:55322", 4 | "WebSocketTransport": "wss://localhost:8081", 5 | "PipeWebSocketTransport": "wss://localhost:8082" 6 | } -------------------------------------------------------------------------------- /src/Lime.Protocol.LoadTests/Tcp/PipeTcpTransportLoadTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Serialization; 3 | using Lime.Transport.Tcp; 4 | using NUnit.Framework; 5 | using Lime.Protocol.Network; 6 | using Lime.Protocol.Server; 7 | 8 | namespace Lime.Protocol.LoadTests.Tcp 9 | { 10 | [TestFixture] 11 | public class PipeTcpTransportLoadTests : TransportLoadTestsBase 12 | { 13 | protected override Uri CreateUri() => new Uri("net.tcp://localhost:9091"); 14 | 15 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 16 | { 17 | return new PipeTcpTransportListener(uri, null, envelopeSerializer, EnvelopePipe.DEFAULT_PAUSE_WRITER_THRESHOLD * 2); 18 | } 19 | 20 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 21 | { 22 | return new PipeTcpTransport(envelopeSerializer, pauseWriterThreshold: EnvelopePipe.DEFAULT_PAUSE_WRITER_THRESHOLD * 2); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Protocol.LoadTests/Tcp/TcpTransportLoadTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Serialization; 3 | using Lime.Transport.Tcp; 4 | using NUnit.Framework; 5 | using Lime.Protocol.Network; 6 | using Lime.Protocol.Server; 7 | 8 | namespace Lime.Protocol.LoadTests.Tcp 9 | { 10 | [TestFixture] 11 | public class TcpTransportLoadTests : TransportLoadTestsBase 12 | { 13 | protected override Uri CreateUri() => new Uri("net.tcp://localhost:9090"); 14 | 15 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 16 | { 17 | return new TcpTransportListener(uri, null, envelopeSerializer, maxBufferSize: TcpTransport.DEFAULT_MAX_BUFFER_SIZE * 2); 18 | } 19 | 20 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 21 | { 22 | return new TcpTransport(envelopeSerializer, maxBufferSize: TcpTransport.DEFAULT_MAX_BUFFER_SIZE * 2); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Protocol.LoadTests/WebSocket/BinaryWebSocketTransportLoadTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.WebSockets; 3 | using Lime.Protocol.Network; 4 | using Lime.Protocol.Serialization; 5 | using Lime.Protocol.Server; 6 | using Lime.Transport.WebSocket; 7 | 8 | namespace Lime.Protocol.LoadTests.WebSocket 9 | { 10 | public class BinaryWebSocketTransportLoadTests : TransportLoadTestsBase 11 | { 12 | protected override Uri CreateUri() => new Uri("ws://localhost:8081"); 13 | 14 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 15 | => new WebSocketTransportListener(new[] { uri }, envelopeSerializer, null, webSocketMessageType: WebSocketMessageType.Binary); 16 | 17 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) => 18 | new ClientWebSocketTransport(envelopeSerializer, 19 | webSocketMessageType: System.Net.WebSockets.WebSocketMessageType.Binary); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Lime.Protocol.LoadTests/WebSocket/PipeWebSocketTransportLoadTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Serialization; 4 | using Lime.Protocol.Server; 5 | using Lime.Transport.WebSocket; 6 | using NUnit.Framework; 7 | 8 | namespace Lime.Protocol.LoadTests.WebSocket 9 | { 10 | [TestFixture] 11 | public class PipeWebSocketTransportLoadTests : TransportLoadTestsBase 12 | { 13 | protected override Uri CreateUri() => new Uri("ws://localhost:8082"); 14 | 15 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 16 | => new PipeWebSocketTransportListener(new[] { uri }, envelopeSerializer, null); 17 | 18 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 19 | => new PipeClientWebSocketTransport(envelopeSerializer); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Lime.Protocol.LoadTests/WebSocket/WebSocketTransportLoadTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Serialization; 4 | using Lime.Protocol.Server; 5 | using Lime.Transport.WebSocket; 6 | using NUnit.Framework; 7 | 8 | namespace Lime.Protocol.LoadTests.WebSocket 9 | { 10 | [TestFixture] 11 | public class WebSocketTransportLoadTests : TransportLoadTestsBase 12 | { 13 | protected override Uri CreateUri() => new Uri("ws://localhost:8081"); 14 | 15 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 16 | => new WebSocketTransportListener(new[] { uri }, envelopeSerializer, null); 17 | 18 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 19 | => new ClientWebSocketTransport(envelopeSerializer); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests.Common/Lime.Protocol.UnitTests.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests/Lime.Protocol.UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | Lime.Protocol.UnitTests 6 | Lime.Protocol.UnitTests 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests/Lime.Protocol.UnitTests.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takenet/lime-csharp/af879a7788ca8033d53831be006750000add9eec/src/Lime.Protocol.UnitTests/Lime.Protocol.UnitTests.snk -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests/Network/X509CertificateInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network.UnitTests 2 | { 3 | public class X509CertificateInfo 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests/Serialization/Models/Schedule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.UnitTests.Serialization.Models 9 | { 10 | [DataContract] 11 | public class Schedule : Document 12 | { 13 | public const string MIME_TYPE = "application/vnd.iris.schedule+json"; 14 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 15 | 16 | public const string WHEN = "when"; 17 | public const string MESSAGE = "message"; 18 | 19 | public Schedule() 20 | : base(MediaType) 21 | { } 22 | 23 | [DataMember(Name = WHEN)] 24 | public DateTimeOffset When { get; set; } 25 | 26 | [DataMember(Name = MESSAGE)] 27 | public Message Message { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Lime.Protocol.UnitTests/Serialization/TestDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Protocol.UnitTests.Serialization 5 | { 6 | [DataContract] 7 | public class TestDocument : Document 8 | { 9 | public const string MIME_TYPE = "application/vnd.takenet.testdocument+json"; 10 | 11 | public TestDocument() 12 | : base(MediaType.Parse(MIME_TYPE)) 13 | { } 14 | 15 | [DataMember(Name = "double")] 16 | public double Double { get; set; } 17 | [DataMember(Name = "date")] 18 | public DateTime Date { get; set; } 19 | [DataMember] 20 | public double? NullableDouble { get; set; } 21 | [DataMember] 22 | public Node Address { get; set; } 23 | [DataMember] 24 | public TestEnum Status { get; set; } 25 | } 26 | 27 | public enum TestEnum 28 | { 29 | None, 30 | Success, 31 | Failure 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Client/IClientProxyFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Lime.Protocol.Network; 6 | 7 | namespace Lime.Protocol.Client 8 | { 9 | public interface IClientProxyFactory 10 | { 11 | T CreateProxy(IClientChannel clientChannel) where T : class; 12 | } 13 | 14 | class ClientProxyFactory : IClientProxyFactory 15 | { 16 | public T CreateProxy(IClientChannel clientChannel) where T : class 17 | { 18 | 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Lime.Protocol/EnvelopeId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol 8 | { 9 | /// 10 | /// Utility class for generating envelope ids. 11 | /// 12 | public static class EnvelopeId 13 | { 14 | /// 15 | /// Generates a new envelope identifier. 16 | /// 17 | /// 18 | public static string NewId() => Guid.NewGuid().ToString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Lime.Protocol/EnvelopeType.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Protocol 4 | { 5 | /// 6 | /// Lists the protocol supported envelope types. 7 | /// 8 | [DataContract] 9 | public enum EnvelopeType 10 | { 11 | /// 12 | /// The message envelope type, 13 | /// used for content transport. 14 | /// 15 | [EnumMember(Value = "message")] 16 | Message, 17 | /// 18 | /// The notification envelope type, 19 | /// used to notify events about messages. 20 | /// 21 | [EnumMember(Value = "notification")] 22 | Notification, 23 | /// 24 | /// The command envelope type, 25 | /// used for request/response request processing. 26 | /// 27 | [EnumMember(Value = "command")] 28 | Command, 29 | /// 30 | /// The session envelope type, 31 | /// used for the communication channel establishment. 32 | /// 33 | [EnumMember(Value = "session")] 34 | Session 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Lime.Protocol/IDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol 8 | { 9 | /// 10 | /// Defines a entity with a . 11 | /// 12 | public interface IDocument 13 | { 14 | /// 15 | /// Gets the type of the media for the document. 16 | /// 17 | /// 18 | MediaType GetMediaType(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Lime.Protocol/IDocumentContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol 2 | { 3 | /// 4 | /// Defines a type that contains a instance. 5 | /// 6 | public interface IDocumentContainer 7 | { 8 | /// 9 | /// Gets the contained document. 10 | /// 11 | Document GetDocument(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/IIdentity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol 8 | { 9 | /// 10 | /// Represents an identity in a domain. 11 | /// 12 | public interface IIdentity 13 | { 14 | /// 15 | /// Identity unique name on his domain. 16 | /// 17 | string Name { get; } 18 | 19 | /// 20 | /// Network domain name of the identity. 21 | /// 22 | string Domain { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Lime.Protocol/INode.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol 2 | { 3 | /// 4 | /// Represents an element of a network. 5 | /// 6 | public interface INode : IIdentity 7 | { 8 | /// 9 | /// The name of the instance used by the node to connect to the network. 10 | /// 11 | string Instance { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/IdentityDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Lime.Protocol 5 | { 6 | /// 7 | /// Represents an identity document. 8 | /// 9 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 10 | public sealed class IdentityDocument : Document 11 | { 12 | public const string MIME_TYPE = "application/vnd.lime.identity"; 13 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 14 | 15 | public IdentityDocument() 16 | : this(null) 17 | { 18 | } 19 | 20 | public IdentityDocument(Identity value) : base(MediaType) 21 | { 22 | Value = value; 23 | } 24 | 25 | /// 26 | /// The value of the document 27 | /// 28 | public Identity Value { get; set; } 29 | 30 | public override string ToString() => Value.ToString(); 31 | 32 | /// 33 | /// Parses the string to a 34 | /// IdentityDocument instance. 35 | /// 36 | /// 37 | /// 38 | public static IdentityDocument Parse(string value) => new IdentityDocument(value); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Lime.Protocol.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | C# LIME protocol stack implementation. 4 | Copyright 2014 Curupira S/A 5 | Lime.Protocol 6 | takenet;andrebires 7 | netstandard2.0;netstandard2.1;net462 8 | Lime.Protocol 9 | Lime.Protocol 10 | lime 11 | http://limeprotocol.org 12 | 1.0.0 13 | true 14 | 1591 15 | 8.0 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Listeners/IChannelListener.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Lime.Protocol.Network; 3 | 4 | namespace Lime.Protocol.Listeners 5 | { 6 | /// 7 | /// Defines a channel listener service. 8 | /// 9 | public interface IChannelListener 10 | { 11 | /// 12 | /// Gets the message listener task. 13 | /// When completed, return the last unconsumed , if there's any. 14 | /// 15 | Task MessageListenerTask { get; } 16 | 17 | /// 18 | /// Gets the notification listener task. 19 | /// When completed, return the last unconsumed , if there's any. 20 | /// 21 | Task NotificationListenerTask { get; } 22 | 23 | /// 24 | /// Gets the command listener task. 25 | /// When completed, return the last unconsumed , if there's any. 26 | /// 27 | Task CommandListenerTask { get; } 28 | 29 | /// 30 | /// Starts this instance. 31 | /// 32 | /// The channel to be listened. 33 | void Start(IEstablishedReceiverChannel channel); 34 | 35 | /// 36 | /// Stops this instance. 37 | /// 38 | void Stop(); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/BufferOverflowException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lime.Protocol.Network 4 | { 5 | public class BufferOverflowException : Exception 6 | { 7 | public BufferOverflowException() : base() 8 | { 9 | } 10 | 11 | public BufferOverflowException(string message) 12 | : base(message) 13 | { 14 | 15 | } 16 | 17 | public BufferOverflowException(string message, Exception innerException) : base(message, innerException) 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/CancellationTokenSourceExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Lime.Protocol.Network 5 | { 6 | public static class CancellationTokenSourceExtensions 7 | { 8 | public static void CancelIfNotRequested(this CancellationTokenSource cts) 9 | { 10 | if (!cts.IsCancellationRequested) cts.Cancel(); 11 | } 12 | 13 | public static void CancelAndDispose(this CancellationTokenSource cts) 14 | { 15 | try 16 | { 17 | cts.CancelIfNotRequested(); 18 | cts.Dispose(); 19 | } 20 | catch (ObjectDisposedException) {} 21 | } 22 | 23 | public static bool IsCancellationRequestedOrDisposed(this CancellationTokenSource cts) 24 | { 25 | if (cts.IsCancellationRequested) return true; 26 | 27 | try 28 | { 29 | _ = cts.Token; 30 | } 31 | catch (ObjectDisposedException) 32 | { 33 | return true; 34 | } 35 | 36 | return false; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/DeferralEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Util; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Lime.Protocol.Network 10 | { 11 | /// 12 | /// Provides a command-style event, where the event generator will only continue the execution after the all the associated handlers finishes they execution. 13 | /// 14 | /// 15 | public class DeferralEventArgs : EventArgs 16 | { 17 | private readonly DeferralManager _deferrals; 18 | 19 | public DeferralEventArgs() 20 | { 21 | _deferrals = new DeferralManager(); 22 | } 23 | 24 | public IDisposable GetDeferral() 25 | { 26 | return _deferrals.GetDeferral(); 27 | } 28 | 29 | public Task WaitForDeferralsAsync(CancellationToken cancellationToken = default(CancellationToken)) 30 | { 31 | return _deferrals.SignalAndWaitAsync(cancellationToken); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/EnvelopeEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol.Network 8 | { 9 | /// 10 | /// Holds the information for a envelope related event. 11 | /// 12 | public class EnvelopeEventArgs : DeferralEventArgs, IEnvelopeContainer where T : Envelope 13 | { 14 | public EnvelopeEventArgs(T envelope) 15 | { 16 | if (envelope == null) throw new ArgumentNullException(nameof(envelope)); 17 | Envelope = envelope; 18 | } 19 | 20 | /// 21 | /// The envelope related to the event. 22 | /// 23 | public T Envelope { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/ExceptionEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Util; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Network 9 | { 10 | /// 11 | /// Provides informations about an event for an exception. 12 | /// 13 | public class ExceptionEventArgs : DeferralEventArgs 14 | { 15 | public ExceptionEventArgs(Exception exception) 16 | { 17 | if (exception == null) throw new ArgumentNullException(nameof(exception)); 18 | Exception = exception; 19 | } 20 | 21 | /// 22 | /// Exception related to the event. 23 | /// 24 | public Exception Exception { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IChannelCommandProcessor.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Network 5 | { 6 | /// 7 | /// Defines the workflow for synchronous command processing. 8 | /// 9 | /// 10 | public interface IChannelCommandProcessor 11 | { 12 | /// 13 | /// Processes the command asynchronous. 14 | /// 15 | /// The command sender channel. 16 | /// The request command. 17 | /// The cancellation token. 18 | /// 19 | Task ProcessCommandAsync(ICommandSenderChannel commandSenderChannel, Command requestCommand, CancellationToken cancellationToken); 20 | 21 | /// 22 | /// Try to submit a command as a result for a pending command request. 23 | /// 24 | /// The response command. 25 | /// 26 | bool TrySubmitCommandResult(Command responseCommand); 27 | 28 | /// 29 | /// Cancels all pending command requests. 30 | /// 31 | void CancelAll(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IChannelInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lime.Protocol.Network 4 | { 5 | /// 6 | /// Provides information about a channel. 7 | /// 8 | public interface IChannelInformation 9 | { 10 | /// 11 | /// Gets the channel session identifier. 12 | /// 13 | string SessionId { get; } 14 | 15 | /// 16 | /// Gets the channel state. 17 | /// 18 | SessionState State { get; } 19 | 20 | /// 21 | /// Gets the channel local node. 22 | /// 23 | Node LocalNode { get; } 24 | 25 | /// 26 | /// Gets the channel remote node. 27 | /// 28 | Node RemoteNode { get; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IEnvelopeContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol.Network 8 | { 9 | public interface IEnvelopeContainer where T : Envelope 10 | { 11 | T Envelope { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IEstablishedChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network 2 | { 3 | /// 4 | /// Defines a channel to exchange envelopes in an established session. 5 | /// 6 | public interface IEstablishedChannel : IEstablishedSenderChannel, IEstablishedReceiverChannel, IMessageChannel, INotificationChannel, ICommandChannel 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IEstablishedReceiverChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network 2 | { 3 | /// 4 | /// Defines a channel to receive envelopes in an established session. 5 | /// 6 | public interface IEstablishedReceiverChannel : IMessageReceiverChannel, INotificationReceiverChannel, 7 | ICommandReceiverChannel 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IEstablishedSenderChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network 2 | { 3 | /// 4 | /// Defines a channel to send envelopes in an established session. 5 | /// 6 | public interface IEstablishedSenderChannel : IMessageSenderChannel, INotificationSenderChannel, 7 | ICommandSenderChannel 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/IReceiverChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network 2 | { 3 | /// 4 | /// Defines a channel to receive envelopes. 5 | /// 6 | public interface IReceiverChannel : IEstablishedReceiverChannel, ISessionReceiverChannel 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/ISenderChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network 2 | { 3 | /// 4 | /// Defines a channel to send envelopes. 5 | /// 6 | public interface ISenderChannel : IEstablishedSenderChannel, ISessionSenderChannel 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/ISessionChannel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Network 9 | { 10 | /// 11 | /// Defines a channel to exchange session envelopes. 12 | /// 13 | public interface ISessionChannel : ISessionSenderChannel, ISessionReceiverChannel 14 | { 15 | 16 | } 17 | 18 | /// 19 | /// Defines a channel to send session envelopes. 20 | /// 21 | public interface ISessionSenderChannel 22 | { 23 | /// 24 | /// Sends a session to the remote node. 25 | /// 26 | /// 27 | /// 28 | /// 29 | Task SendSessionAsync(Session session, CancellationToken cancellationToken); 30 | } 31 | 32 | /// 33 | /// Defines a channel to receive session envelopes. 34 | /// 35 | public interface ISessionReceiverChannel 36 | { 37 | /// 38 | /// Receives a session from the remote node. 39 | /// 40 | /// The cancellation token. 41 | /// 42 | Task ReceiveSessionAsync(CancellationToken cancellationToken); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/ITransportInformation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net; 3 | 4 | namespace Lime.Protocol.Network 5 | { 6 | /// 7 | /// Provides information about a transport connection. 8 | /// 9 | public interface ITransportInformation 10 | { 11 | /// 12 | /// Gets the current transport compression option. 13 | /// 14 | SessionCompression Compression { get; } 15 | 16 | /// 17 | /// Gets the current transport encryption option. 18 | /// 19 | SessionEncryption Encryption { get; } 20 | 21 | /// 22 | /// Indicates if the transport is connected. 23 | /// 24 | bool IsConnected { get; } 25 | 26 | /// 27 | /// Gets the local endpoint address. 28 | /// 29 | string LocalEndPoint { get; } 30 | 31 | /// 32 | /// Gets the remote endpoint address. 33 | /// 34 | string RemoteEndPoint { get; } 35 | 36 | /// 37 | /// Gets specific transport options informations. 38 | /// 39 | IReadOnlyDictionary Options { get; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/ChannelModuleBase.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Network.Modules 5 | { 6 | public abstract class ChannelModuleBase : IChannelModule where T : Envelope, new() 7 | { 8 | public virtual void OnStateChanged(SessionState state) 9 | { 10 | 11 | } 12 | 13 | public virtual Task OnReceivingAsync(T envelope, CancellationToken cancellationToken) 14 | { 15 | return Task.FromResult(envelope); 16 | } 17 | 18 | public virtual Task OnSendingAsync(T envelope, CancellationToken cancellationToken) 19 | { 20 | return Task.FromResult(envelope); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/ExtractContainerMessageModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lime.Protocol.Network.Modules 8 | { 9 | /// 10 | /// Extract the value of container documents directly to the message. 11 | /// 12 | /// 13 | public class ExtractContainerMessageModule : ChannelModuleBase 14 | { 15 | public override Task OnReceivingAsync(Message envelope, CancellationToken cancellationToken) 16 | { 17 | if (envelope.Content is IDocumentContainer) 18 | { 19 | envelope.Content = ((IDocumentContainer)envelope.Content).GetDocument(); 20 | } 21 | 22 | return base.OnReceivingAsync(envelope, cancellationToken); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/Resend/DiscardDeadMessageHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol.Util; 4 | 5 | namespace Lime.Protocol.Network.Modules.Resend 6 | { 7 | public sealed class DiscardDeadMessageHandler : IDeadMessageHandler 8 | { 9 | public static DiscardDeadMessageHandler Instance { get; } = new DiscardDeadMessageHandler(); 10 | 11 | public Task HandleDeadMessageAsync(Message message, IChannelInformation channelInformation, 12 | CancellationToken cancellationToken) 13 | => TaskUtil.CompletedTask; 14 | } 15 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/Resend/IDeadMessageHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Network.Modules.Resend 5 | { 6 | /// 7 | /// Defines a service for handling dead messages (messages without notification after retries) for the class. 8 | /// 9 | public interface IDeadMessageHandler 10 | { 11 | /// 12 | /// Handles a channel dead message. 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | Task HandleDeadMessageAsync(Message message, IChannelInformation channelInformation, CancellationToken cancellationToken); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/Resend/IKeyProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network.Modules.Resend 2 | { 3 | /// 4 | /// Create the keys to be used by the module. 5 | /// 6 | public interface IKeyProvider 7 | { 8 | /// 9 | /// Gets a key for the specified channel. 10 | /// 11 | /// 12 | /// 13 | string GetChannelKey(IChannel channel); 14 | 15 | /// 16 | /// Gets a key for the specified message. 17 | /// 18 | /// 19 | /// 20 | /// 21 | string GetMessageKey(Message message, IChannel channel); 22 | 23 | /// 24 | /// Gets a message key for the specified notification. 25 | /// 26 | /// 27 | /// 28 | /// 29 | string GetMessageKey(Notification notification, IChannel channel); 30 | } 31 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/Modules/Resend/KeyProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Network.Modules.Resend 2 | { 3 | public sealed class KeyProvider : IKeyProvider 4 | { 5 | public static KeyProvider Instance { get; } = new KeyProvider(); 6 | 7 | public string GetChannelKey(IChannel channel) => $"{channel.RemoteNode}:{channel.LocalNode}".ToLowerInvariant(); 8 | 9 | public string GetMessageKey(Message message, IChannel channel) => $"{(message.To ?? channel.RemoteNode).ToIdentity()}:{message.Id}".ToLowerInvariant(); 10 | 11 | public string GetMessageKey(Notification notification, IChannel channel) => $"{(notification.From ?? channel.RemoteNode).ToIdentity()}:{notification.Id}".ToLowerInvariant(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Network/TraceWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol.Util; 4 | 5 | namespace Lime.Protocol.Network 6 | { 7 | /// 8 | /// Traces into the default .NET tracers. 9 | /// 10 | public sealed class TraceWriter : ITraceWriter 11 | { 12 | public Task TraceAsync(string data, DataOperation operation) 13 | { 14 | Trace.WriteLine(data, operation.ToString()); 15 | return TaskUtil.CompletedTask; 16 | } 17 | 18 | public bool IsEnabled => Trace.Listeners.Count > 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Lime.Protocol/NodeDocument.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Protocol 4 | { 5 | /// 6 | /// Represents a node document. 7 | /// 8 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 9 | public sealed class NodeDocument : Document 10 | { 11 | public const string MIME_TYPE = "application/vnd.lime.node"; 12 | public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE); 13 | 14 | public NodeDocument() 15 | : this(null) 16 | 17 | { 18 | } 19 | 20 | public NodeDocument(Node value) 21 | : base(MediaType) 22 | { 23 | Value = value; 24 | } 25 | 26 | /// 27 | /// The value of the document 28 | /// 29 | public Identity Value { get; set; } 30 | 31 | public override string ToString() => Value.ToString(); 32 | 33 | /// 34 | /// Parses the string to a 35 | /// IdentityDocument instance. 36 | /// 37 | /// 38 | /// 39 | public static NodeDocument Parse(string value) => new NodeDocument(value); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Reason.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol 9 | { 10 | /// 11 | /// Represents a known reason for 12 | /// events occurred during the client-server 13 | /// interactions. 14 | /// 15 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 16 | public class Reason 17 | { 18 | public const string CODE_KEY = "code"; 19 | public const string DESCRIPTION_KEY = "description"; 20 | 21 | [DataMember(Name = CODE_KEY)] 22 | public int Code { get; set; } 23 | 24 | [DataMember(Name = DESCRIPTION_KEY)] 25 | public string Description { get; set; } 26 | 27 | public override string ToString() 28 | { 29 | return string.Format("{0} (Code {1})", Description, Code); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/Authentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Security 9 | { 10 | /// 11 | /// Base class for the supported 12 | /// authentication schemes 13 | /// 14 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 15 | public abstract class Authentication 16 | { 17 | private AuthenticationScheme _scheme; 18 | 19 | public Authentication(AuthenticationScheme scheme) 20 | { 21 | _scheme = scheme; 22 | } 23 | 24 | public AuthenticationScheme GetAuthenticationScheme() 25 | { 26 | return _scheme; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/AuthenticationScheme.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Protocol.Security 4 | { 5 | 6 | /// 7 | /// Defines the valid authentication schemes values. 8 | /// 9 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 10 | public enum AuthenticationScheme 11 | { 12 | /// 13 | /// The server doesn't requires a client credential, and provides a temporary identity to the node. 14 | /// Some restriction may apply to guest sessions, like the inability of sending some commands or other nodes may want to block messages originated by guest identities. 15 | /// 16 | [EnumMember(Value = "guest")] 17 | Guest, 18 | /// 19 | /// Username and password authentication. 20 | /// 21 | [EnumMember(Value = "plain")] 22 | Plain, 23 | /// 24 | /// Transport layer authentication. 25 | /// 26 | [EnumMember(Value = "transport")] 27 | Transport, 28 | /// 29 | /// Key authentication. 30 | /// 31 | [EnumMember(Value = "key")] 32 | Key, 33 | /// 34 | /// Third-party authentication. 35 | /// 36 | [EnumMember(Value = "external")] 37 | External 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/GuestAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Security 9 | { 10 | /// 11 | /// Defines a guest authentication scheme 12 | /// 13 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 14 | public class GuestAuthentication : Authentication 15 | { 16 | public GuestAuthentication() 17 | : base(AuthenticationScheme.Guest) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/IAuthenticatableTransport.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Security 5 | { 6 | /// 7 | /// Defines a transport that supports authentication. 8 | /// 9 | public interface IAuthenticatableTransport : ITransport 10 | { 11 | /// 12 | /// Authenticate the identity in the transport layer. 13 | /// 14 | /// The identity to be authenticated 15 | /// Indicates if the identity is authenticated 16 | Task AuthenticateAsync(Identity identity); 17 | } 18 | 19 | /// 20 | /// Indicates the role of an identity in a domain. 21 | /// 22 | public enum DomainRole 23 | { 24 | /// 25 | /// The identity is unknown in the domain. 26 | /// 27 | Unknown, 28 | /// 29 | /// The identity is a member of the domain. 30 | /// 31 | Member, 32 | /// 33 | /// The identity is an authority of the domain. 34 | /// 35 | Authority, 36 | /// 37 | /// The identity is an authority of the domain and its sub-domains. 38 | /// 39 | RootAuthority 40 | } 41 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/KeyAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Protocol.Security 4 | { 5 | /// 6 | /// Defines a authentication scheme that uses a key for authentication. 7 | /// Should be used only with encrypted sessions. 8 | /// 9 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 10 | public class KeyAuthentication : Authentication 11 | { 12 | public const string KEY_KEY = "key"; 13 | 14 | public KeyAuthentication() 15 | : base(AuthenticationScheme.Key) 16 | { 17 | 18 | } 19 | 20 | 21 | /// 22 | /// Base64 representation of the identity key. 23 | /// 24 | [DataMember(Name = KEY_KEY)] 25 | public string Key { get; set; } 26 | 27 | /// 28 | /// Set a plain key to a Base64 representation. 29 | /// 30 | /// 31 | public void SetToBase64Key(string key) 32 | { 33 | Key = string.IsNullOrWhiteSpace(key) ? key : key.ToBase64(); 34 | } 35 | 36 | /// 37 | /// Gets the plain key decoded from the Base64 representation. 38 | /// 39 | /// 40 | public string GetFromBase64Key() 41 | { 42 | return string.IsNullOrWhiteSpace(Key) ? Key : Key.FromBase64(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Security/TransportAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Lime.Protocol.Security 4 | { 5 | /// 6 | /// Defines a transport layer authentication scheme. 7 | /// 8 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 9 | public class TransportAuthentication : Authentication 10 | { 11 | public TransportAuthentication() 12 | : base(AuthenticationScheme.Transport) 13 | { 14 | } 15 | 16 | /// 17 | /// The domain role determined by the method call. 18 | /// This value should not be serialized. 19 | /// 20 | [IgnoreDataMember] 21 | public DomainRole? DomainRole { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/DictionaryExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Lime.Protocol.Serialization 5 | { 6 | public static class DictionaryExtensions 7 | { 8 | /// 9 | /// Removes the element with the specified key from the dictionary and adds an element with the provided key and value. 10 | /// Note: This call is not synchronized. 11 | /// 12 | /// The type of the key. 13 | /// The type of the value. 14 | /// The dictionary. 15 | /// The key. 16 | /// The value. 17 | [Obsolete("Do not use this. Use the dictionary direct key access.")] 18 | public static void RemoveAndAdd(this IDictionary dictionary, TKey key, TValue value) 19 | { 20 | dictionary.Remove(key); 21 | dictionary.Add(key, value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/IDocumentSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Serialization 2 | { 3 | public interface IDocumentSerializer 4 | { 5 | string Serialize(Document document); 6 | 7 | Document Deserialize(string value, MediaType mediaType); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/IEnvelopeSerializer.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers; 2 | using System.IO; 3 | 4 | namespace Lime.Protocol.Serialization 5 | { 6 | /// 7 | /// Base interface for envelope serializers. 8 | /// 9 | public interface IEnvelopeSerializer 10 | { 11 | /// 12 | /// Serialize an envelope to a string. 13 | /// 14 | /// 15 | /// 16 | string Serialize(Envelope envelope); 17 | 18 | /// 19 | /// Deserialize an envelope from a string. 20 | /// 21 | /// 22 | /// 23 | Envelope Deserialize(string envelopeString); 24 | 25 | /// 26 | /// Deserialize an envelope from a text reader. 27 | /// 28 | /// 29 | /// 30 | T Deserialize(TextReader reader) 31 | where T : Envelope; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/JsonDocumentExtensions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Lime.Protocol.Serialization 4 | { 5 | public static class JsonDocumentExtensions 6 | { 7 | public static string ToJson(this JsonDocument document, JsonSerializerSettings settings) => JsonConvert.SerializeObject(document, settings); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/Newtonsoft/Converters/AuthenticationJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Security; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Reflection; 5 | 6 | namespace Lime.Protocol.Serialization.Newtonsoft.Converters 7 | { 8 | public class AuthenticationJsonConverter : JsonConverter 9 | { 10 | public override bool CanWrite => false; 11 | 12 | public override bool CanConvert(Type objectType) 13 | { 14 | return typeof (Authentication).IsAssignableFrom(objectType); 15 | } 16 | 17 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, global::Newtonsoft.Json.JsonSerializer serializer) 18 | { 19 | // The serialization is handled by the container class 20 | return null; 21 | } 22 | 23 | public override void WriteJson(JsonWriter writer, object value, global::Newtonsoft.Json.JsonSerializer serializer) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/Newtonsoft/Converters/IdentityJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Lime.Protocol.Serialization.Newtonsoft.Converters 5 | { 6 | public class IdentityJsonConverter : StringBasedTypeJsonConverter 7 | { 8 | protected override Identity CreateInstance(string tokenValue) 9 | { 10 | return Identity.Parse(tokenValue); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/Newtonsoft/Converters/LimeUriJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Lime.Protocol.Serialization.Newtonsoft.Converters 5 | { 6 | public class LimeUriJsonConverter : StringBasedTypeJsonConverter 7 | { 8 | protected override LimeUri CreateInstance(string tokenValue) 9 | { 10 | return LimeUri.Parse(tokenValue); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/Newtonsoft/Converters/MediaTypeJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Lime.Protocol.Serialization.Newtonsoft.Converters 5 | { 6 | public class MediaTypeJsonConverter : StringBasedTypeJsonConverter 7 | { 8 | protected override MediaType CreateInstance(string tokenValue) 9 | { 10 | return MediaType.Parse(tokenValue); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Serialization/Newtonsoft/Converters/NodeJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Lime.Protocol.Serialization.Newtonsoft.Converters 5 | { 6 | public class NodeJsonConverter : StringBasedTypeJsonConverter 7 | { 8 | protected override Node CreateInstance(string tokenValue) 9 | { 10 | return Node.Parse(tokenValue); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/AuthenticationResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Security; 3 | 4 | namespace Lime.Protocol.Server 5 | { 6 | /// 7 | /// Represents the result of a session authentication. 8 | /// 9 | public sealed class AuthenticationResult 10 | { 11 | public AuthenticationResult(DomainRole domainRole, Authentication roundtrip = null) 12 | { 13 | DomainRole = domainRole; 14 | Roundtrip = roundtrip; 15 | } 16 | 17 | /// 18 | /// The domain role for the specified node. 19 | /// 20 | public DomainRole DomainRole { get; } 21 | 22 | /// 23 | /// The authentication roundtrip. 24 | /// 25 | public Authentication Roundtrip { get; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/INodeRegistry.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Server 5 | { 6 | /// 7 | /// Defines a service to register channel nodes instances for the server. 8 | /// 9 | public interface INodeRegistry 10 | { 11 | /// 12 | /// Try register a node channel. If success, it should return the registered node address; otherwise, returns null. 13 | /// Note that the returned node instance may be different from the provided in the parameters. 14 | /// 15 | Task TryRegisterAsync(Node node, IServerChannel channel, CancellationToken cancellationToken); 16 | 17 | /// 18 | /// Get a channel for the provided node address. 19 | /// 20 | Task GetAsync(Node node, CancellationToken cancellationToken); 21 | 22 | /// 23 | /// Unregister a channel for the node. 24 | /// 25 | Task UnregisterAsync(Node node, CancellationToken cancellationToken); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/IServer.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Server 2 | { 3 | /// 4 | /// Defines a basic server infrastructure. 5 | /// 6 | public interface IServer : IStartable, IStoppable 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/IStartable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Server 5 | { 6 | public interface IStartable 7 | { 8 | /// 9 | /// Start listening for connections. 10 | /// 11 | /// The cancellation token. 12 | /// 13 | Task StartAsync(CancellationToken cancellationToken); 14 | } 15 | 16 | public static class StartableExtensions 17 | { 18 | /// 19 | /// Start listening for connections. 20 | /// 21 | /// 22 | public static Task StartAsync(this IStartable startable) => startable.StartAsync(CancellationToken.None); 23 | } 24 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/IStoppable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lime.Protocol.Server 5 | { 6 | public interface IStoppable 7 | { 8 | /// 9 | /// Stops the tranport listener. 10 | /// 11 | /// The cancellation token. 12 | /// 13 | Task StopAsync(CancellationToken cancellationToken); 14 | } 15 | 16 | public static class StoppableExtensions 17 | { 18 | /// 19 | /// Stops the tranport listener. 20 | /// 21 | /// 22 | public static Task StopAsync(this IStoppable stoppable) => stoppable.StopAsync(CancellationToken.None); 23 | } 24 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/ITransportListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lime.Protocol.Server 7 | { 8 | /// 9 | /// Defines a listener interface for the transports. 10 | /// 11 | public interface ITransportListener : IStartable, IStoppable 12 | { 13 | /// 14 | /// Gets the transport listener URIs. 15 | /// 16 | Uri[] ListenerUris { get; } 17 | 18 | /// 19 | /// Accepts a new transport connection. 20 | /// 21 | /// 22 | /// 23 | Task AcceptTransportAsync(CancellationToken cancellationToken); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Server/TransportEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Server 9 | { 10 | public class TransportEventArgs : EventArgs 11 | { 12 | public TransportEventArgs(ITransport transport) 13 | { 14 | if (transport == null) 15 | { 16 | throw new ArgumentNullException("transport"); 17 | } 18 | 19 | this.Transport = transport; 20 | } 21 | 22 | public ITransport Transport { get; private set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Lime.Protocol/SessionCompression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Lime.Protocol.Security; 4 | 5 | namespace Lime.Protocol 6 | { 7 | 8 | /// 9 | /// Defines the valid session compression values. 10 | /// 11 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 12 | public enum SessionCompression 13 | { 14 | /// 15 | /// The session is not compressed. 16 | /// 17 | [EnumMember(Value = "none")] 18 | None, 19 | /// 20 | /// The session is using the GZip 21 | /// algorithm for compression. 22 | /// 23 | [EnumMember(Value = "gzip")] 24 | GZip 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Lime.Protocol/SessionEncryption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Lime.Protocol.Security; 4 | 5 | namespace Lime.Protocol 6 | { 7 | 8 | /// 9 | /// Defines the valid session encryption values. 10 | /// 11 | [DataContract(Namespace = "http://limeprotocol.org/2014")] 12 | public enum SessionEncryption 13 | { 14 | /// 15 | /// The session is not encrypted. 16 | /// 17 | [EnumMember(Value = "none")] 18 | None, 19 | /// 20 | /// The session is encrypted by TLS 21 | /// (Transport Layer Security). 22 | /// 23 | [EnumMember(Value = "tls")] 24 | TLS 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Tracing/LimeActivitySource.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace Lime.Protocol.Tracing 4 | { 5 | /// 6 | /// Provides the ActivitySource for the Lime.Protocol 7 | /// 8 | public static class LimeActivitySource 9 | { 10 | /// 11 | /// The name of the ActivitySource for the Lime.Protocol 12 | /// 13 | public const string LimeProtocol = "Lime.Protocol"; 14 | 15 | /// 16 | /// Gets the ActivitySource for the Lime.Protocol to be used when creating activities. 17 | /// 18 | public static readonly ActivitySource Instance = new ActivitySource(LimeProtocol); 19 | } 20 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Tracing/TraceContext.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Protocol.Tracing 2 | { 3 | /// 4 | /// Defines the Trace Context constants. 5 | /// 6 | public static class TraceContext 7 | { 8 | /// 9 | /// The trace parent header name of the W3C trace context. 10 | /// 11 | public const string TraceParent = "traceparent"; 12 | 13 | /// 14 | /// The trace state header name of the W3C trace context. 15 | /// 16 | public const string TraceState = "tracestate"; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Lime.Protocol/Util/DeferralManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lime.Protocol.Util 9 | { 10 | /// 11 | /// 12 | /// 13 | public sealed class DeferralManager 14 | { 15 | private readonly AsyncCountdownEvent _count = new AsyncCountdownEvent(1); 16 | 17 | public IDisposable GetDeferral() 18 | { 19 | return new Deferral(_count); 20 | } 21 | 22 | public Task SignalAndWaitAsync(CancellationToken cancellationToken) 23 | { 24 | _count.Signal(); 25 | return _count.WaitAsync(cancellationToken); 26 | } 27 | 28 | private sealed class Deferral : IDisposable 29 | { 30 | private AsyncCountdownEvent _count; 31 | 32 | public Deferral(AsyncCountdownEvent count) 33 | { 34 | _count = count; 35 | _count.AddCount(); 36 | } 37 | 38 | void IDisposable.Dispose() 39 | { 40 | if (_count == null) 41 | return; 42 | _count.Signal(); 43 | _count = null; 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Lime.Protocol/Util/TaskUtil.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Lime.Protocol.Util 4 | { 5 | public static class TaskUtil 6 | { 7 | /// 8 | /// Gets a completed task. 9 | /// 10 | public static readonly Task CompletedTask = Task.FromResult(null); 11 | 12 | /// 13 | /// Gets a completed task with true result. 14 | /// 15 | public static readonly Task TrueCompletedTask = Task.FromResult(true); 16 | 17 | /// 18 | /// Gets a completed task with true result. 19 | /// 20 | public static readonly Task FalseCompletedTask = Task.FromResult(false); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Lime.Protocol; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Lime.Sample.AspNetCore.Controllers 11 | { 12 | [ApiController] 13 | [Route("[controller]")] 14 | public class ValuesController : ControllerBase 15 | { 16 | [HttpGet] 17 | [Route("/")] 18 | public IEnumerable GetValues() 19 | { 20 | return new[] 21 | { 22 | "value1", 23 | "value2", 24 | "value3", 25 | }; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Lime.Sample.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Listeners/CommandListener.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol; 4 | using Lime.Transport.AspNetCore; 5 | using Lime.Transport.AspNetCore.Listeners; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Lime.Sample.AspNetCore.Listeners 9 | { 10 | public class CommandListener : CommandListenerBase 11 | { 12 | private readonly ILogger _logger; 13 | private readonly ChannelContext _channelContext; 14 | 15 | public CommandListener(ILogger logger, ChannelContext channelContext) 16 | : base(c => c.Status == CommandStatus.Pending) 17 | { 18 | _logger = logger; 19 | _channelContext = channelContext; 20 | } 21 | 22 | public override async Task OnCommandAsync(Command command, CancellationToken cancellationToken) 23 | { 24 | _logger.LogInformation("Command received"); 25 | 26 | var responseCommand = new Command() 27 | { 28 | Id = command.Id, 29 | Method = command.Method, 30 | Status = CommandStatus.Success 31 | }; 32 | 33 | await _channelContext.Channel.SendCommandAsync(responseCommand, cancellationToken); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Listeners/NotificationListener.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol; 4 | using Lime.Transport.AspNetCore; 5 | using Lime.Transport.AspNetCore.Listeners; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Lime.Sample.AspNetCore.Listeners 9 | { 10 | public class NotificationListener : NotificationListenerBase 11 | { 12 | private readonly ILogger _logger; 13 | 14 | public NotificationListener(ILogger logger) 15 | { 16 | _logger = logger; 17 | } 18 | 19 | public override Task OnNotificationAsync(Notification notification, CancellationToken cancellationToken) 20 | { 21 | _logger.LogInformation("Notification {Id} received with event {Event}", notification.Id, notification.Event); 22 | 23 | return Task.CompletedTask; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Lime.Sample.AspNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:20405", 8 | "sslPort": 44329 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "Lime.Sample.AspNetCore": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": "true", 23 | "launchBrowser": true, 24 | "launchUrl": "swagger", 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Lime.Sample.AspNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | 4 | "Logging": { 5 | "LogLevel": { 6 | "Default": "Information", 7 | "Microsoft": "Warning", 8 | "Microsoft.Hosting.Lifetime": "Information" 9 | } 10 | }, 11 | "AllowedHosts": "*" 12 | } 13 | -------------------------------------------------------------------------------- /src/Lime.Sample.Client/DebugTraceWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol.Network; 4 | using Lime.Protocol.Util; 5 | 6 | namespace Lime.Sample.Client 7 | { 8 | public class DebugTraceWriter : ITraceWriter 9 | { 10 | public Task TraceAsync(string data, DataOperation operation) 11 | { 12 | Debug.WriteLine($"{operation} - {data}"); 13 | return TaskUtil.CompletedTask; 14 | } 15 | 16 | public bool IsEnabled 17 | { 18 | get { return true; } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Lime.Sample.Client/Lime.Sample.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | Exe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Lime.Sample.Server/DebugTraceWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol.Network; 4 | 5 | namespace Lime.Sample.Server 6 | { 7 | public class DebugTraceWriter : ITraceWriter 8 | { 9 | private string _id; 10 | 11 | public DebugTraceWriter(string id) 12 | { 13 | _id = id; 14 | } 15 | 16 | #region ITraceWriter Members 17 | 18 | public Task TraceAsync(string data, DataOperation operation) 19 | { 20 | Debug.WriteLine("Id: {0} - Operation: {1} - Data: {2}", _id, operation, data); 21 | return Task.FromResult(null); 22 | } 23 | 24 | public bool IsEnabled 25 | { 26 | get { return true; } 27 | } 28 | 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Lime.Sample.Server/Lime.Sample.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | Exe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/FakeCommandListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using Lime.Transport.AspNetCore.Listeners; 3 | 4 | namespace Lime.Transport.AspNetCore.UnitTests 5 | { 6 | public class FakeCommandListener : FakeEnvelopeListener, ICommandListener 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/FakeEnvelopeListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Lime.Protocol; 6 | using Lime.Transport.AspNetCore.Listeners; 7 | 8 | namespace Lime.Transport.AspNetCore.UnitTests 9 | { 10 | public class FakeEnvelopeListener : IEnvelopeListener where T : Envelope, new() 11 | { 12 | public FakeEnvelopeListener() 13 | { 14 | Envelopes = new List(); 15 | } 16 | 17 | public List Envelopes { get; } 18 | 19 | public Predicate Filter { get; } = _ => true; 20 | public Task OnEnvelopeAsync(T envelope, CancellationToken cancellationToken) 21 | { 22 | Envelopes.Add(envelope); 23 | return Task.CompletedTask; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/FakeMessageListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using Lime.Transport.AspNetCore.Listeners; 3 | 4 | namespace Lime.Transport.AspNetCore.UnitTests 5 | { 6 | public class FakeMessageListener : FakeEnvelopeListener, IMessageListener 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/FakeNotificationListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | using Lime.Transport.AspNetCore.Listeners; 3 | 4 | namespace Lime.Transport.AspNetCore.UnitTests 5 | { 6 | public class FakeNotificationListener : FakeEnvelopeListener, INotificationListener 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/Lime.Transport.AspNetCore.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore.UnitTests/Middlewares/FakeRequestDelegate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNetCore.Http; 4 | 5 | namespace Lime.Transport.AspNetCore.UnitTests.Middlewares 6 | { 7 | public class FakeRequestDelegate 8 | { 9 | public FakeRequestDelegate() 10 | { 11 | NextCalls = 0; 12 | HttpContexts = new List(); 13 | } 14 | 15 | public int NextCalls { get; private set; } 16 | 17 | public List HttpContexts { get; } 18 | 19 | public Task Next(HttpContext context) 20 | { 21 | NextCalls++; 22 | HttpContexts.Add(context); 23 | return Task.CompletedTask; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/AuthenticationHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Security; 5 | using Lime.Protocol.Server; 6 | 7 | namespace Lime.Transport.AspNetCore 8 | { 9 | /// 10 | /// Defines a handler for authenticating the an identity. 11 | /// 12 | public delegate Task AuthenticationHandler(Identity identity, Authentication authentication, CancellationToken cancellationToken); 13 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/ChannelContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol; 3 | using Lime.Transport.AspNetCore.Transport; 4 | 5 | namespace Lime.Transport.AspNetCore 6 | { 7 | /// 8 | /// Provide context information about the connected channels. 9 | /// 10 | public sealed class ChannelContext 11 | { 12 | private readonly IChannelProvider _channelProvider; 13 | 14 | public ChannelContext(ISenderChannel channel, IChannelProvider channelProvider) 15 | { 16 | Channel = channel; 17 | _channelProvider = channelProvider; 18 | } 19 | 20 | /// 21 | /// Gets the channel which the current envelope was received from. 22 | /// 23 | public ISenderChannel Channel { get; } 24 | 25 | /// 26 | /// Gets a channel for the specified remote note. 27 | /// 28 | /// 29 | /// 30 | public ISenderChannel? GetChannel(Node node) => _channelProvider.GetChannel(node); 31 | } 32 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/ChannelContextProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lime.Transport.AspNetCore 4 | { 5 | internal class ChannelContextProvider 6 | { 7 | private ChannelContext? _context; 8 | 9 | public void SetContext(ChannelContext requestContext) 10 | { 11 | if (_context != null) 12 | { 13 | throw new InvalidOperationException("The channel context has already been set"); 14 | } 15 | 16 | _context = requestContext; 17 | } 18 | 19 | public ChannelContext GetContext() 20 | { 21 | if (_context == null) 22 | { 23 | throw new InvalidOperationException("The channel context was not been set"); 24 | } 25 | 26 | return _context; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/EndPointOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Transport.AspNetCore 2 | { 3 | public abstract class EndPointOptions 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/HttpEndPointOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Lime.Transport.AspNetCore 5 | { 6 | public sealed class HttpEndPointOptions : EndPointOptions 7 | { 8 | public string MessagesPath { get; set; } = "/messages"; 9 | public string NotificationsPath { get; set; } = "/notifications"; 10 | public string CommandsPath { get; set; } = "/commands"; 11 | 12 | public bool IsValid() => new[] { MessagesPath, NotificationsPath, CommandsPath}.Distinct().Count() == 3; 13 | internal bool ContainsPath(string path) => 14 | CommandsPath.Equals(path, StringComparison.OrdinalIgnoreCase) || 15 | NotificationsPath.Equals(path, StringComparison.OrdinalIgnoreCase) || 16 | MessagesPath.Equals(path, StringComparison.OrdinalIgnoreCase); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/ISenderChannel.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.Network; 2 | 3 | namespace Lime.Transport.AspNetCore 4 | { 5 | /// 6 | /// Defines a channel for sending envelopes. 7 | /// 8 | public interface ISenderChannel : IMessageSenderChannel, INotificationSenderChannel, ICommandSenderChannel, ICommandProcessor, IChannelInformation 9 | { 10 | /// 11 | /// Gets information about the channel transport. 12 | /// 13 | ITransportInformation Transport { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Lime.Transport.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | nullable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | <_Parameter1>Lime.Transport.AspNetCore.UnitTests 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Listeners/ICommandListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | 3 | namespace Lime.Transport.AspNetCore.Listeners 4 | { 5 | /// 6 | /// Defines a service for receiving envelopes. 7 | /// 8 | public interface ICommandListener : IEnvelopeListener 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Listeners/IEnvelopeListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Lime.Protocol; 5 | 6 | namespace Lime.Transport.AspNetCore.Listeners 7 | { 8 | /// 9 | /// Defines an envelope receiving service. 10 | /// 11 | /// 12 | public interface IEnvelopeListener where T : Envelope, new() 13 | { 14 | /// 15 | /// Gets the filter for receiving envelopes. 16 | /// 17 | Predicate Filter { get; } 18 | 19 | /// 20 | /// Receives an envelope instance. 21 | /// 22 | /// 23 | /// 24 | /// 25 | Task OnEnvelopeAsync(T envelope, CancellationToken cancellationToken); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Listeners/IMessageListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | 3 | namespace Lime.Transport.AspNetCore.Listeners 4 | { 5 | /// 6 | /// Defines a service for receiving envelopes. 7 | /// 8 | public interface IMessageListener : IEnvelopeListener 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Listeners/INotificationListener.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | 3 | namespace Lime.Transport.AspNetCore.Listeners 4 | { 5 | /// 6 | /// Defines a service for receiving envelopes. 7 | /// 8 | public interface INotificationListener : IEnvelopeListener 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Listeners/NotificationListenerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Lime.Protocol; 5 | 6 | namespace Lime.Transport.AspNetCore.Listeners 7 | { 8 | /// 9 | /// Defines a base class for receiving instances from the connected clients. 10 | /// 11 | public abstract class NotificationListenerBase : INotificationListener 12 | { 13 | protected NotificationListenerBase() 14 | : this (_ => true) 15 | { 16 | 17 | } 18 | protected NotificationListenerBase(Predicate filter) 19 | { 20 | Filter = filter ?? throw new ArgumentNullException(nameof(filter)); 21 | } 22 | 23 | public Predicate Filter { get; } 24 | 25 | public Task OnEnvelopeAsync(Notification envelope, CancellationToken cancellationToken) => OnNotificationAsync(envelope, cancellationToken); 26 | 27 | public abstract Task OnNotificationAsync(Notification notification, CancellationToken cancellationToken); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/RegistrationHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Server; 5 | 6 | namespace Lime.Transport.AspNetCore 7 | { 8 | /// 9 | /// Defines a handler for registering a node. The implementation should return a node address for the specified candidate node. 10 | /// 11 | public delegate Task RegistrationHandler(Node candidate, IServerChannel channel, CancellationToken cancellationToken); 12 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Transport/ChannelProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using Lime.Protocol; 3 | 4 | namespace Lime.Transport.AspNetCore.Transport 5 | { 6 | public sealed class ChannelProvider : IChannelProvider 7 | { 8 | private readonly ConcurrentDictionary _establishedChannels; 9 | 10 | public ChannelProvider() 11 | { 12 | _establishedChannels = new ConcurrentDictionary(); 13 | } 14 | 15 | public ISenderChannel? GetChannel(Node node) => _establishedChannels.TryGetValue(node, out var c) ? c : null; 16 | public void AddChannel(Node node, SenderChannelAdapter senderChannel) 17 | { 18 | _establishedChannels[node] = senderChannel; 19 | } 20 | public void RemoveChannel(Node node) 21 | { 22 | _establishedChannels.TryRemove(node, out _); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Transport/IChannelProvider.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol; 2 | 3 | namespace Lime.Transport.AspNetCore.Transport 4 | { 5 | /// 6 | /// Provides an instance of a registered channel. 7 | /// 8 | public interface IChannelProvider 9 | { 10 | ISenderChannel? GetChannel(Node node); 11 | void AddChannel(Node node, SenderChannelAdapter senderChannel); 12 | void RemoveChannel(Node node); 13 | } 14 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Transport/Kestrel/README.txt: -------------------------------------------------------------------------------- 1 | These internal classes were copied from ASP.NET repository on Github. -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/Transport/TcpClientAdapter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net.Sockets; 3 | using System.Threading.Tasks; 4 | using Lime.Transport.Tcp; 5 | using Microsoft.AspNetCore.Connections; 6 | using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; 7 | 8 | namespace Lime.Transport.AspNetCore.Transport 9 | { 10 | internal sealed class TcpClientAdapter : ITcpClient 11 | { 12 | private readonly ConnectionContext _context; 13 | private bool _closed; 14 | 15 | public TcpClientAdapter(ConnectionContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public Stream GetStream() => new DuplexPipeStream(_context.Transport.Input, _context.Transport.Output); 21 | 22 | public Task ConnectAsync(string host, int port) => Task.CompletedTask; 23 | 24 | public bool Connected => !_context.ConnectionClosed.IsCancellationRequested && !_closed; 25 | 26 | public void Close() 27 | { 28 | _context.Transport.Input.Complete(); 29 | _context.Transport.Output.Complete(); 30 | _closed = true; 31 | } 32 | 33 | public Socket Client => null!; 34 | } 35 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/TransportEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Security.Cryptography.X509Certificates; 3 | 4 | namespace Lime.Transport.AspNetCore 5 | { 6 | /// 7 | /// Provide configurations about an endpoint. 8 | /// 9 | public class TransportEndPoint 10 | { 11 | /// 12 | /// The transport protocol to be used for communication. 13 | /// 14 | public TransportType Transport { get; set; } = TransportType.Tcp; 15 | 16 | /// 17 | /// The endpoint for listening for new connections. 18 | /// 19 | public IPEndPoint EndPoint { get; set; } = new IPEndPoint(IPAddress.Any, 55321); 20 | 21 | /// 22 | /// The endpoint for listening for new connections. 23 | /// 24 | public string EndPointValue 25 | { 26 | get => EndPoint.ToString(); 27 | set => EndPoint = IPEndPoint.Parse(value); 28 | } 29 | 30 | /// 31 | /// Defines the server certificate, for TLS connections. (HTTPS, WSS and TCP+TLS). 32 | /// 33 | public X509Certificate2? ServerCertificate { get; set; } 34 | 35 | /// 36 | /// Specific endpoint settings. 37 | /// 38 | public EndPointOptions? Options { get; set; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/TransportType.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Transport.AspNetCore 2 | { 3 | /// 4 | /// The supported transport types. 5 | /// 6 | public enum TransportType 7 | { 8 | /// 9 | /// Uses the TCP transport. 10 | /// 11 | Tcp, 12 | 13 | /// 14 | /// Uses the WebSocket transport. 15 | /// 16 | WebSocket, 17 | 18 | /// 19 | /// Uses the HTTP transport. 20 | /// 21 | Http 22 | } 23 | } -------------------------------------------------------------------------------- /src/Lime.Transport.AspNetCore/UnregistrationHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Lime.Protocol; 4 | using Lime.Protocol.Server; 5 | 6 | namespace Lime.Transport.AspNetCore 7 | { 8 | /// 9 | /// Defines a handler for unregistering a node. 10 | /// 11 | public delegate Task UnregistrationHandler(Node node, IServerChannel channel, CancellationToken cancellationToken); 12 | } -------------------------------------------------------------------------------- /src/Lime.Transport.Redis.UnitTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("Lime.Transport.Redis.UnitTests")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("355ee108-16fd-4846-af5f-b633063bf9e9")] 20 | -------------------------------------------------------------------------------- /src/Lime.Transport.Redis/ConnectionMultiplexerFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using StackExchange.Redis; 7 | 8 | namespace Lime.Transport.Redis 9 | { 10 | public class ConnectionMultiplexerFactory : IConnectionMultiplexerFactory 11 | { 12 | public async Task CreateAsync(ConfigurationOptions configurationOptions) 13 | { 14 | var connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(configurationOptions).ConfigureAwait(false); 15 | connectionMultiplexer.PreserveAsyncOrder = false; 16 | return connectionMultiplexer; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Lime.Transport.Redis/IConnectionMultiplexerFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using StackExchange.Redis; 3 | 4 | namespace Lime.Transport.Redis 5 | { 6 | public interface IConnectionMultiplexerFactory 7 | { 8 | Task CreateAsync(ConfigurationOptions configurationOptions); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Lime.Transport.Redis/Lime.Transport.Redis.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Lime.Transport.Redis 5 | $version$ 6 | Lime.Transport.Redis 7 | takenet 8 | takenet,andrebires 9 | http://limeprotocol.org 10 | https://raw.githubusercontent.com/takenet/lime/master/LICENSE 11 | false 12 | Redis transport for LIME protocol. 13 | Copyright © 2015 Curupira S/A 14 | lime 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp.UnitTests/Lime.Transport.Tcp.UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | Lime.Transport.Tcp.UnitTests 6 | Lime.Transport.Tcp.UnitTests 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp.UnitTests/PipeTcpTransportListenerTests.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.UnitTests.Network; 2 | using System; 3 | using Lime.Protocol.Network; 4 | using Lime.Protocol.Server; 5 | using NUnit.Framework; 6 | 7 | namespace Lime.Transport.Tcp.UnitTests 8 | { 9 | [TestFixture] 10 | public class PipeTcpTransportListenerTests : TransportListenerTestsBase 11 | { 12 | protected override ITransport CreateClientTransport() => new PipeTcpTransport(EnvelopeSerializer); 13 | 14 | protected override Uri CreateListenerUri() => new Uri("net.tcp://localhost:5332"); 15 | 16 | protected override ITransportListener CreateTransportListener() 17 | => new PipeTcpTransportListener(ListenerUri, null, EnvelopeSerializer, traceWriter: TraceWriter.Object); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp.UnitTests/TcpTransportListenerTests.cs: -------------------------------------------------------------------------------- 1 | using Lime.Protocol.UnitTests.Network; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Lime.Protocol.Network; 8 | using Lime.Protocol.Server; 9 | using NUnit.Framework; 10 | 11 | namespace Lime.Transport.Tcp.UnitTests 12 | { 13 | [TestFixture] 14 | public class TcpTransportListenerTests : TransportListenerTestsBase 15 | { 16 | protected override ITransport CreateClientTransport() => new TcpTransport(EnvelopeSerializer); 17 | 18 | protected override Uri CreateListenerUri() => new Uri("net.tcp://localhost:5322"); 19 | 20 | protected override ITransportListener CreateTransportListener() 21 | => new TcpTransportListener(ListenerUri, null, EnvelopeSerializer, traceWriter: TraceWriter.Object); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp.UnitTests/X509CertificateInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Lime.Transport.Tcp.UnitTests 2 | { 3 | public class X509CertificateInfo 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp/Lime.Transport.Tcp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | C# LIME tcp transport library 5 | Copyright ₢ 2014 Curupira S/A 6 | Lime.Transport.Tcp 7 | takenet;andrebires 8 | netstandard2.1 9 | Lime.Transport.Tcp 10 | Lime.Transport.Tcp 11 | lime 12 | http://limeprotocol.org 13 | 1.0.0 14 | true 15 | 8.0 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | <_Parameter1>Lime.Transport.AspNetCore 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Lime.Transport.Tcp/LimeTcpActivitySource.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace Lime.Transport.Tcp 4 | { 5 | /// 6 | /// Provides the ActivitySource for the Lime.Protocol TCP transport 7 | /// 8 | public static class LimeTcpActivitySource 9 | { 10 | /// 11 | /// The name of the ActivitySource for the Lime.Protocol TCP transport 12 | /// 13 | public const string LimeTcp = "Lime.Transport.Tcp"; 14 | 15 | /// 16 | /// Gets the ActivitySource for the Lime.Protocol to be used when creating activities. 17 | /// 18 | public static readonly ActivitySource Instance = new ActivitySource(LimeTcp); 19 | } 20 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket.UnitTests/PipeWebSocketTransportListenerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Server; 4 | using Lime.Protocol.UnitTests.Network; 5 | using NUnit.Framework; 6 | 7 | namespace Lime.Transport.WebSocket.UnitTests 8 | { 9 | [TestFixture] 10 | public class PipeWebSocketTransportListenerTests : TransportListenerTestsBase 11 | { 12 | protected override ITransport CreateClientTransport() => new PipeClientWebSocketTransport(EnvelopeSerializer); 13 | 14 | protected override Uri CreateListenerUri() => new Uri("ws://localhost:8092"); 15 | 16 | protected override ITransportListener CreateTransportListener() 17 | => new PipeWebSocketTransportListener(new[] { ListenerUri }, EnvelopeSerializer, null, TraceWriter.Object); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket.UnitTests/PipeWebSocketTransportTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Serialization; 3 | using Lime.Protocol.Server; 4 | using Lime.Protocol.UnitTests.Common.Network; 5 | using Lime.Transport.WebSocket.Kestrel; 6 | using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; 7 | using NUnit.Framework; 8 | using ITransport = Lime.Protocol.Network.ITransport; 9 | 10 | namespace Lime.Transport.WebSocket.UnitTests 11 | { 12 | [TestFixture] 13 | public class PipeWebSocketTransportTests : TransportTestsBase 14 | { 15 | protected override Uri CreateListenerUri() => new Uri("ws://localhost:8091"); 16 | 17 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 18 | { 19 | return new PipeWebSocketTransportListener(new[] { uri }, envelopeSerializer, null, TraceWriter, closeGracefully: false); 20 | } 21 | 22 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 23 | { 24 | return new PipeClientWebSocketTransport(envelopeSerializer, closeGracefully: false); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket.UnitTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using NUnit.Framework; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Lime.Transport.WebSocket.UnitTests")] 12 | [assembly: AssemblyTrademark("")] 13 | 14 | // Setting ComVisible to false makes the types in this assembly not visible 15 | // to COM components. If you need to access a type in this assembly from 16 | // COM, set the ComVisible attribute to true on that type. 17 | [assembly: ComVisible(false)] 18 | 19 | // The following GUID is for the ID of the typelib if this project is exposed to COM 20 | [assembly: Guid("fa70c038-fadd-4c79-bc43-61492d667e98")] -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket.UnitTests/WebSocketTransportListenerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Network; 3 | using Lime.Protocol.Server; 4 | using Lime.Protocol.UnitTests.Network; 5 | using NUnit.Framework; 6 | 7 | namespace Lime.Transport.WebSocket.UnitTests 8 | { 9 | [TestFixture] 10 | public class WebSocketTransportListenerTests : TransportListenerTestsBase 11 | { 12 | protected override ITransport CreateClientTransport() => new ClientWebSocketTransport(EnvelopeSerializer); 13 | 14 | protected override Uri CreateListenerUri() => new Uri("ws://localhost:8082"); 15 | 16 | protected override ITransportListener CreateTransportListener() 17 | => new WebSocketTransportListener(new[] { ListenerUri }, EnvelopeSerializer, null, TraceWriter.Object); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket.UnitTests/WebSocketTransportTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lime.Protocol.Serialization; 3 | using Lime.Protocol.Server; 4 | using Lime.Protocol.UnitTests.Common.Network; 5 | using Lime.Transport.WebSocket.Kestrel; 6 | using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; 7 | using NUnit.Framework; 8 | using ITransport = Lime.Protocol.Network.ITransport; 9 | 10 | namespace Lime.Transport.WebSocket.UnitTests 11 | { 12 | [TestFixture] 13 | public class WebSocketTransportTests : TransportTestsBase 14 | { 15 | protected override Uri CreateListenerUri() => new Uri("ws://localhost:8081"); 16 | 17 | protected override ITransportListener CreateTransportListener(Uri uri, IEnvelopeSerializer envelopeSerializer) 18 | { 19 | return new WebSocketTransportListener(new[] { uri }, envelopeSerializer, null, TraceWriter, closeGracefully: false); 20 | } 21 | 22 | protected override ITransport CreateClientTransport(IEnvelopeSerializer envelopeSerializer) 23 | { 24 | return new ClientWebSocketTransport(envelopeSerializer, closeGracefully: false); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket/Lime.Transport.WebSocket.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Lime.Transport.WebSocket 5 | $version$ 6 | Lime.Transport.WebSocket 7 | takenet 8 | takenet,andrebires 9 | http://limeprotocol.org 10 | https://raw.githubusercontent.com/takenet/lime/master/LICENSE 11 | false 12 | WebSocket transport for LIME protocol. 13 | Copyright © 2015 Curupira S/A 14 | lime 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket/LimeWebSocketActivitySource.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace Lime.Transport.WebSocket 4 | { 5 | /// 6 | /// Provides the ActivitySource for the Lime.Protocol WebSocket transport 7 | /// 8 | public static class LimeWebSocketActivitySource 9 | { 10 | /// 11 | /// The name of the ActivitySource for the Lime.Protocol WebSocket transport 12 | /// 13 | public const string LimeWebSocket = "Lime.Transport.WebSocket"; 14 | 15 | /// 16 | /// Gets the ActivitySource for the Lime.Protocol to be used when creating activities. 17 | /// 18 | public static readonly ActivitySource Instance = new ActivitySource(LimeWebSocket); 19 | } 20 | } -------------------------------------------------------------------------------- /src/Lime.Transport.WebSocket/X509CertificateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography.X509Certificates; 3 | 4 | namespace Lime.Transport.WebSocket 5 | { 6 | /// 7 | /// Provides information about a stored certificate. 8 | /// 9 | public sealed class X509CertificateInfo 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The thumbprint. 15 | /// The store. 16 | /// 17 | public X509CertificateInfo(string thumbprint, StoreName store = StoreName.My) 18 | { 19 | if (thumbprint == null) throw new ArgumentNullException(nameof(thumbprint)); 20 | Thumbprint = thumbprint; 21 | Store = store; 22 | } 23 | 24 | /// 25 | /// Gets the certificate thumbprint. 26 | /// 27 | /// 28 | /// The thumbprint. 29 | /// 30 | public string Thumbprint { get; } 31 | 32 | /// 33 | /// Gets the certificate store. 34 | /// 35 | /// 36 | /// The store. 37 | /// 38 | public StoreName Store { get; } 39 | } 40 | } --------------------------------------------------------------------------------