public static IEventStoreConnection Create(IPEndPoint endPoint, TcpType tcpType = TcpType.Ssl, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), endPoint.ToESTcpUri(), $"ESC-{TestContext.CurrentContext?.Test?.Name}-{Interlocked.Increment(ref _nextConnId)}")); }
public static IEventStoreConnection To(MiniNode miniNode, TcpType tcpType, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), miniNode.TcpEndPoint.ToESTcpUri(), $"ESC-{Interlocked.Increment(ref _nextConnId)}")); }
public static IEventStoreConnection To(MiniNode miniNode, TcpType tcpType, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), tcpType == TcpType.Ssl ? miniNode.TcpSecEndPoint.ToESTcpUri() : miniNode.TcpEndPoint.ToESTcpUri(), string.Format("ESC-{0}", Interlocked.Increment(ref _nextConnId)))); }
private static ConnectionSettingsBuilder Settings(TcpType tcpType, UserCredentials userCredentials) { var settings = ConnectionSettings.Create() .SetDefaultUserCredentials(userCredentials) .UseCustomLogger(ClientApiLoggerBridge.Default) .EnableVerboseLogging() .LimitReconnectionsTo(10) .LimitAttemptsForOperationTo(1) .SetTimeoutCheckPeriodTo(TimeSpan.FromMilliseconds(100)) .SetReconnectionDelayTo(TimeSpan.Zero) .FailOnNoServerResponse() //.SetOperationTimeoutTo(TimeSpan.FromDays(1)) ; if (tcpType == TcpType.Ssl) { settings.DisableServerCertificateValidation(); } else { settings.DisableTls(); } return(settings); }
public static IEventStoreConnection Create(IPEndPoint endPoint, TcpType tcpType = TcpType.Normal, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), endPoint.ToESTcpUri(), string.Format("ESC-{0}", Interlocked.Increment(ref _nextConnId)))); }
public TcpClient(TcpType tcpType) { _clientEvents = new PInvoke.mk_tcp_client_events { OnConnect = new PInvoke.on_mk_tcp_client_connect(mk_tcp_client_connect), OnData = new PInvoke.on_mk_tcp_client_data(mk_tcp_client_data), OnDisconnect = new PInvoke.on_mk_tcp_client_disconnect(mk_tcp_client_disconnect), OnManager = new PInvoke.on_mk_tcp_client_manager(on_mk_tcp_client_manager) }; this._id = PInvoke.ZLMediaKitMethod.mk_tcp_client_create(ref _clientEvents, tcpType); }
/// <summary> /// 开启tcp服务器 /// </summary> /// <param name="port">监听端口号,0则为随机</param> /// <param name="tcpServerType">服务器类型</param> /// <returns></returns> internal static Task <TcpSession> TcpServerStart(ushort port, TcpType tcpServerType) { return(Task.Run(() => { ushort serverPort = PInvoke.ZLMediaKitMethod.mk_tcp_server_start(port, tcpServerType); var autoResetEvent = new TcpSessionAutoResetEvent(serverPort); _autoWaitEventDict.Add(autoResetEvent); if (autoResetEvent.AutoResetEvent.WaitOne(AppConst.WaitTcpCreateMillisecond)) { _autoWaitEventDict.Remove(autoResetEvent); return new TcpSession(autoResetEvent.TcpSession); } _autoWaitEventDict.Remove(autoResetEvent); throw new TimeoutException("等待 ZLMediaKit on_mk_tcp_session_create回调超时"); }).ContinueWith(GeneralTask.WriteFaultedLog)); }
private static ConnectionSettingsBuilder Settings(TcpType tcpType, UserCredentials userCredentials) { var settings = ConnectionSettings.Create() .SetDefaultUserCredentials(userCredentials) .UseCustomLogger(ClientApiLoggerBridge.Default) .EnableVerboseLogging() .LimitReconnectionsTo(10) .LimitRetriesForOperationTo(100) .SetTimeoutCheckPeriodTo(TimeSpan.FromMilliseconds(100)) .SetReconnectionDelayTo(TimeSpan.Zero) .FailOnNoServerResponse() .SetOperationTimeoutTo(TimeSpan.FromDays(1)); if (tcpType == TcpType.Ssl) settings.UseSslConnection("ES", false); return settings; }
private static ConnectionSettingsBuilder Settings(TcpType tcpType, ILogger customerLogger) { var settings = ConnectionSettings.Create() //.UseCustomLogger(customerLogger) .EnableVerboseLogging() .LimitReconnectionsTo(10) .LimitRetriesForOperationTo(100) .SetTimeoutCheckPeriodTo(TimeSpan.FromMilliseconds(100)) .SetReconnectionDelayTo(TimeSpan.Zero) .FailOnNoServerResponse() .SetOperationTimeoutTo(TimeSpan.FromDays(1)); if (tcpType == TcpType.Ssl) { settings.UseSslConnection("ES", false); } return(settings); }
private static ConnectionSettingsBuilder Settings(TcpType tcpType, UserCredentials userCredentials) { var settings = ConnectionSettings.Create() .SetDefaultUserCredentials(userCredentials) .UseCustomLogger(new NunitLogger(TestContext.Out)) .EnableVerboseLogging() .LimitReconnectionsTo(10) .LimitRetriesForOperationTo(100) .SetTimeoutCheckPeriodTo(TimeSpan.FromMilliseconds(100)) .SetReconnectionDelayTo(TimeSpan.Zero) .FailOnNoServerResponse() .SetOperationTimeoutTo(TimeSpan.FromDays(1)); if (tcpType == TcpType.Ssl) { settings.UseSslConnection("ES", false); } return(settings); }
private EthernetPacket GenerateEthernetPacket(ushort destinationPort, TcpType packetType) { TcpPacket tcpPacket; switch (packetType) { case TcpType.Syn: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, true, false); break; case TcpType.Rst: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, false, true); break; default: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, false, false); break; } var ipPacket = NetworkUtils.CreateIpV4Packet(localIp, destinationIp, tcpPacket); return(NetworkUtils.CreateEthernetPacket(localMacAddress, destinationMacAddress, ipPacket)); }
public event_store_connection_should(TcpType tcpType) { _tcpType = tcpType; }
public static IEventStoreConnection To(MiniNode miniNode, TcpType tcpType, UserCredentials userCredentials = null) { return EventStoreConnection.Create(Settings(tcpType, userCredentials), tcpType == TcpType.Ssl ? miniNode.TcpSecEndPoint.ToESTcpUri() : miniNode.TcpEndPoint.ToESTcpUri(), string.Format("ESC-{0}", Interlocked.Increment(ref _nextConnId))); }
public static IEventStoreConnection Create(IPEndPoint endPoint, TcpType tcpType = TcpType.Normal, UserCredentials userCredentials = null) { return EventStoreConnection.Create(Settings(tcpType, userCredentials), endPoint.ToESTcpUri(), string.Format("ESC-{0}", Interlocked.Increment(ref _nextConnId))); }
public static IEventStoreConnection To(MiniNode miniNode, TcpType tcpType, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), tcpType == TcpType.Ssl ? miniNode.TcpSecEndPoint : miniNode.TcpEndPoint)); }
//private static bool _running; public static IEventStoreConnection Create(IPEndPoint endPoint, TcpType tcpType = TcpType.Normal, UserCredentials userCredentials = null) { return(EventStoreConnection.Create(Settings(tcpType, userCredentials), endPoint)); }
internal static extern ushort mk_tcp_server_start(ushort port, TcpType type);
public static IEventStoreConnection Create(string connection, ILogger logger, TcpType tcpType = TcpType.Normal) { return(EventStoreConnection.Create(Settings(tcpType, logger), new Uri(connection), string.Format("ESC-{0}", Interlocked.Increment(ref _nextConnId)))); }
private EthernetPacket GenerateEthernetPacket(ushort destinationPort, TcpType packetType) { TcpPacket tcpPacket; switch (packetType) { case TcpType.Syn: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, true, false); break; case TcpType.Rst: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, false, true); break; default: tcpPacket = NetworkUtils.CreateTcpPacket(localPort, destinationPort, false, false); break; } var ipPacket = NetworkUtils.CreateIpV4Packet(localIp, destinationIp, tcpPacket); return NetworkUtils.CreateEthernetPacket(localMacAddress, destinationMacAddress, ipPacket); }
public connect(TcpType tcpType) { _tcpType = tcpType; }
internal static extern System.IntPtr mk_tcp_client_create(ref mk_tcp_client_events events, TcpType type);
public static IEventStoreConnection To(MiniNode miniNode, TcpType tcpType, UserCredentials userCredentials = null) { return EventStoreConnection.Create(Settings(tcpType, userCredentials), tcpType == TcpType.Ssl ? miniNode.TcpSecEndPoint : miniNode.TcpEndPoint); }
//private static bool _running; public static IEventStoreConnection Create(IPEndPoint endPoint, TcpType tcpType = TcpType.Normal, UserCredentials userCredentials = null) { return EventStoreConnection.Create(Settings(tcpType, userCredentials), endPoint); }