Messaging: Add binding class
This commit is contained in:
parent
33a95ba46d
commit
c082222c80
@ -96,6 +96,7 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="MailSender.vb" />
|
||||
<Compile Include="WCF\Binding.vb" />
|
||||
<Compile Include="WCF\Channel.vb" />
|
||||
<Compile Include="WCF\Constants.vb" />
|
||||
<Compile Include="WCF\ServerAddress.vb" />
|
||||
|
||||
31
Messaging/WCF/Binding.vb
Normal file
31
Messaging/WCF/Binding.vb
Normal file
@ -0,0 +1,31 @@
|
||||
Imports System.Net
|
||||
Imports System.ServiceModel
|
||||
Imports System.Xml
|
||||
|
||||
Namespace WCF
|
||||
Public Class Binding
|
||||
Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding
|
||||
Return New NetTcpBinding() With {
|
||||
.MaxReceivedMessageSize = Constants.ChannelSettings.MAX_RECEIVED_MESSAGE_SIZE,
|
||||
.MaxBufferSize = Constants.ChannelSettings.MAX_BUFFER_SIZE,
|
||||
.MaxBufferPoolSize = Constants.ChannelSettings.MAX_BUFFER_POOL_SIZE,
|
||||
.TransferMode = TransferMode.Streamed,
|
||||
.Security = New NetTcpSecurity() With {
|
||||
.Mode = SecurityMode.Transport,
|
||||
.Transport = New TcpTransportSecurity() With {
|
||||
.ClientCredentialType = AuthenticationMode
|
||||
}
|
||||
},
|
||||
.ReaderQuotas = New XmlDictionaryReaderQuotas() With {
|
||||
.MaxArrayLength = Constants.ChannelSettings.MAX_ARRAY_LENGTH,
|
||||
.MaxStringContentLength = Constants.ChannelSettings.MAX_STRING_CONTENT_LENGTH
|
||||
}
|
||||
}
|
||||
End Function
|
||||
|
||||
Public Shared Function GetAddress(pHost As String, pPort As Integer, pName As String) As Uri
|
||||
Return New Uri($"net.tcp://{pHost}:{pPort}/DigitalData/Services/{pName}")
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@ -11,9 +11,9 @@ Namespace WCF
|
||||
|
||||
Public Event Reconnect As EventHandler
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pServerAddress As ServerAddress)
|
||||
Public Sub New(pLogConfig As LogConfig, pServerAddress As ServerAddress, Optional pName As String = "Main")
|
||||
MyBase.New(pLogConfig)
|
||||
ChannelFactory = GetChannelFactory(pServerAddress)
|
||||
ChannelFactory = GetChannelFactory(pServerAddress, pName)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
@ -40,30 +40,13 @@ Namespace WCF
|
||||
''' <param name="pName">The service name, will be: net.tcp://ip:port/DigitalData/Services/[name]</param>
|
||||
''' <param name="pAddress">The service address, in the form of ip address and port</param>
|
||||
''' <returns></returns>
|
||||
Private Function GetChannelFactory(pAddress As ServerAddress, Optional pName As String = "Main") As ChannelFactory(Of TChannel)
|
||||
Dim oBinding = GetBinding()
|
||||
Dim oAddress = New EndpointAddress($"net.tcp://{pAddress.Host}:{pAddress.Port}/DigitalData/Services/{pName}")
|
||||
Private Function GetChannelFactory(pAddress As ServerAddress, pName As String) As ChannelFactory(Of TChannel)
|
||||
Dim oBinding = Binding.GetBinding()
|
||||
Dim oAddress = New EndpointAddress(Binding.GetAddress(pAddress.Host, pAddress.Port, pName))
|
||||
Dim oFactory = New ChannelFactory(Of TChannel)(oBinding, oAddress)
|
||||
Return oFactory
|
||||
End Function
|
||||
|
||||
Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding
|
||||
Return New NetTcpBinding() With {
|
||||
.MaxReceivedMessageSize = Constants.ChannelSettings.MAX_RECEIVED_MESSAGE_SIZE,
|
||||
.MaxBufferSize = Constants.ChannelSettings.MAX_BUFFER_SIZE,
|
||||
.MaxBufferPoolSize = Constants.ChannelSettings.MAX_BUFFER_POOL_SIZE,
|
||||
.TransferMode = TransferMode.Streamed,
|
||||
.Security = New NetTcpSecurity() With {
|
||||
.Mode = SecurityMode.Transport,
|
||||
.Transport = New TcpTransportSecurity() With {
|
||||
.ClientCredentialType = AuthenticationMode
|
||||
}
|
||||
},
|
||||
.ReaderQuotas = New XmlDictionaryReaderQuotas() With {
|
||||
.MaxArrayLength = Constants.ChannelSettings.MAX_ARRAY_LENGTH,
|
||||
.MaxStringContentLength = Constants.ChannelSettings.MAX_STRING_CONTENT_LENGTH
|
||||
}
|
||||
}
|
||||
End Function
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user