本文整理汇总了C#中MessageBusType类的典型用法代码示例。如果您正苦于以下问题:C# MessageBusType类的具体用法?C# MessageBusType怎么用?C# MessageBusType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageBusType类属于命名空间,在下文中一共展示了MessageBusType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReconnectExceedingReconnectWindowDisconnectsWithFastBeatInterval
public void ReconnectExceedingReconnectWindowDisconnectsWithFastBeatInterval(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
// Test cannot be async because if we do host.ShutDown() after an await the connection stops.
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(keepAlive: 9, messageBusType: messageBusType);
var connection = CreateHubConnection(host);
using (connection)
{
var disconnectWh = new ManualResetEventSlim();
connection.Closed += () =>
{
disconnectWh.Set();
};
SetReconnectDelay(host.Transport, TimeSpan.FromSeconds(15));
connection.Start(host.Transport).Wait();
// Without this the connection start and reconnect can race with eachother resulting in a deadlock.
Thread.Sleep(TimeSpan.FromSeconds(3));
// Set reconnect window to zero so the second we attempt to reconnect we can ensure that the reconnect window is verified.
((Client.IConnection)connection).ReconnectWindow = TimeSpan.FromSeconds(0);
host.Shutdown();
Assert.True(disconnectWh.Wait(TimeSpan.FromSeconds(15)), "Closed never fired");
}
}
}
开发者ID:kietnha,项目名称:SignalR,代码行数:34,代码来源:ConnectionFacts.cs
示例2: UseMessageBus
protected void UseMessageBus(MessageBusType type, IDependencyResolver resolver, int streams = 1)
{
IMessageBus bus = null;
switch (type)
{
case MessageBusType.Default:
break;
case MessageBusType.Fake:
case MessageBusType.FakeMultiStream:
bus = new FakeScaleoutBus(resolver, streams);
break;
case MessageBusType.SqlServer:
break;
case MessageBusType.ServiceBus:
break;
case MessageBusType.Redis:
break;
default:
break;
}
if (bus != null)
{
resolver.Register(typeof(IMessageBus), () => bus);
}
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:27,代码来源:HostedTest.cs
示例3: Initialize
public void Initialize(int? keepAlive,
int? connectionTimeout,
int? disconnectTimeout,
int? transportConnectTimeout,
bool enableAutoRejoiningGroups,
MessageBusType type = MessageBusType.Default)
{
if (type != MessageBusType.Default)
{
throw new NotImplementedException();
}
// Use a configuration file to specify values
string content = String.Format(_webConfigTemplate.Value,
keepAlive,
connectionTimeout,
disconnectTimeout,
transportConnectTimeout,
enableAutoRejoiningGroups,
_logFileName);
File.WriteAllText(_webConfigPath, content);
Url = _siteManager.GetSiteUrl(ExtraData);
}
开发者ID:kabotnik,项目名称:SignalR,代码行数:25,代码来源:IISExpressTestHost.cs
示例4: CanInvokeMethodsAndReceiveMessagesFromValidTypedHub
public async Task CanInvokeMethodsAndReceiveMessagesFromValidTypedHub(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
using (var connection = CreateHubConnection(host))
{
var hub = connection.CreateHubProxy("ValidTypedHub");
var echoTcs = new TaskCompletionSource<string>();
var pingWh = new ManualResetEventSlim();
hub.On<string>("Echo", message => echoTcs.TrySetResult(message));
hub.On("Ping", pingWh.Set);
await connection.Start(host.TransportFactory());
hub.InvokeWithTimeout("Echo", "arbitrary message");
Assert.True(echoTcs.Task.Wait(TimeSpan.FromSeconds(10)));
Assert.Equal("arbitrary message", echoTcs.Task.Result);
hub.InvokeWithTimeout("Ping");
Assert.True(pingWh.Wait(TimeSpan.FromSeconds(10)));
}
}
}
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:26,代码来源:TypedHubFacts.cs
示例5: SuccessiveTimeoutTest
public async Task SuccessiveTimeoutTest(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
// Arrange
var mre = new AsyncManualResetEvent(false);
host.Initialize(keepAlive: 5, messageBusType: messageBusType);
var connection = CreateConnection(host, "/my-reconnect");
using (connection)
{
connection.Reconnected += () =>
{
mre.Set();
};
await connection.Start(host.Transport);
((Client.IConnection)connection).KeepAliveData = new KeepAliveData(TimeSpan.FromMilliseconds(300));
// Assert that Reconnected is called
Assert.True(await mre.WaitAsync(TimeSpan.FromSeconds(15)));
// Assert that Reconnected is called again
mre.Reset();
Assert.True(await mre.WaitAsync(TimeSpan.FromSeconds(15)));
// Clean-up
mre.Dispose();
}
}
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:32,代码来源:KeepAliveFacts.cs
示例6: ReconnectionSuccesfulTest
public void ReconnectionSuccesfulTest(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
// Arrange
var mre = new ManualResetEventSlim(false);
host.Initialize(keepAlive: null, messageBusType: messageBusType);
var connection = CreateConnection(host, "/my-reconnect");
using (connection)
{
((Client.IConnection)connection).KeepAliveData = new KeepAliveData(TimeSpan.FromSeconds(2));
connection.Reconnected += () =>
{
mre.Set();
};
connection.Start(host.Transport).Wait();
// Assert
Assert.True(mre.Wait(TimeSpan.FromSeconds(10)));
// Clean-up
mre.Dispose();
}
}
}
开发者ID:RyanChristensen,项目名称:SignalR,代码行数:28,代码来源:KeepAliveFacts.cs
示例7: MarkActiveStopsConnectionIfCalledAfterExtendedPeriod
public void MarkActiveStopsConnectionIfCalledAfterExtendedPeriod(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
var connection = CreateHubConnection(host);
using (connection)
{
var disconnectWh = new ManualResetEventSlim();
connection.Closed += () =>
{
disconnectWh.Set();
};
connection.Start(host.Transport).Wait();
// The MarkActive interval should check the reconnect window. Since this is short it should force the connection to disconnect.
((Client.IConnection)connection).ReconnectWindow = TimeSpan.FromSeconds(1);
Assert.True(disconnectWh.Wait(TimeSpan.FromSeconds(15)), "Closed never fired");
}
}
}
开发者ID:kietnha,项目名称:SignalR,代码行数:25,代码来源:ConnectionFacts.cs
示例8: TransportTimesOutIfNoInitMessage
public async Task TransportTimesOutIfNoInitMessage(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
var mre = new AsyncManualResetEvent();
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(transportConnectTimeout: 1, messageBusType: messageBusType);
HubConnection hubConnection = CreateHubConnection(host, "/no-init");
IHubProxy proxy = hubConnection.CreateHubProxy("DelayedOnConnectedHub");
using (hubConnection)
{
try
{
await hubConnection.Start(host.Transport);
}
catch
{
mre.Set();
}
Assert.True(await mre.WaitAsync(TimeSpan.FromSeconds(10)));
}
}
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:27,代码来源:HubProxyFacts.cs
示例9: ReconnectionSuccesfulTest
public async Task ReconnectionSuccesfulTest(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
// Arrange
var mre = new AsyncManualResetEvent(false);
host.Initialize(keepAlive: null, messageBusType: messageBusType);
var connection = CreateConnection(host, "/my-reconnect");
if (transportType == TransportType.LongPolling)
{
((Client.Transports.LongPollingTransport)host.Transport).ReconnectDelay = TimeSpan.Zero;
}
using (connection)
{
((Client.IConnection)connection).KeepAliveData = new KeepAliveData(TimeSpan.FromSeconds(2));
connection.Reconnected += () =>
{
mre.Set();
};
await connection.Start(host.Transport);
Assert.True(await mre.WaitAsync(TimeSpan.FromSeconds(10)));
// Clean-up
mre.Dispose();
}
}
}
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:32,代码来源:KeepAliveFacts.cs
示例10: Initialize
public void Initialize(int? keepAlive = -1,
int? connectionTimeout = 110,
int? disconnectTimeout = 30,
int? transportConnectTimeout = 5,
bool enableAutoRejoiningGroups = false,
MessageBusType type = MessageBusType.Default)
{
// nothing to initialize since it is external!
}
开发者ID:nirmana,项目名称:SignalR,代码行数:9,代码来源:ExternalTestHost.cs
示例11: ReconnectFiresAfterHostShutdown
public async Task ReconnectFiresAfterHostShutdown(TransportType transportType, MessageBusType messageBusType)
{
var serverRestarts = 0;
var serverReconnects = 0;
var host = new ServerRestarter(app =>
{
var config = new ConnectionConfiguration
{
Resolver = new DefaultDependencyResolver()
};
UseMessageBus(messageBusType, config.Resolver);
app.MapSignalR<MyReconnect>("/endpoint", config);
serverRestarts++;
serverReconnects = 0;
config.Resolver.Register(typeof(MyReconnect), () => new MyReconnect(() => serverReconnects++));
});
using (host)
{
using (var connection = CreateConnection("http://foo/endpoint"))
{
var transport = CreateTransport(transportType, host);
var pollEvent = new AsyncManualResetEvent();
var reconnectedEvent = new AsyncManualResetEvent();
host.OnPoll = () =>
{
pollEvent.Set();
};
connection.Reconnected += () =>
{
reconnectedEvent.Set();
};
await connection.Start(transport);
// Wait for the /poll before restarting the server
Assert.True(await pollEvent.WaitAsync(TimeSpan.FromSeconds(15)), "Timed out waiting for poll request");
host.Restart();
Assert.True(await reconnectedEvent.WaitAsync(TimeSpan.FromSeconds(15)), "Timed out waiting for client side reconnect");
Assert.Equal(2, serverRestarts);
Assert.Equal(1, serverReconnects);
}
}
}
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:53,代码来源:ReconnectFacts.cs
示例12: ReconnectFiresAfterHostShutdown
public void ReconnectFiresAfterHostShutdown(TransportType transportType, MessageBusType messageBusType)
{
var persistentConnections = new List<MyReconnect>();
var host = new ServerRestarter(app =>
{
var config = new ConnectionConfiguration
{
Resolver = new DefaultDependencyResolver()
};
UseMessageBus(messageBusType, config.Resolver);
app.MapSignalR<MyReconnect>("/endpoint", config);
var conn = new MyReconnect();
config.Resolver.Register(typeof(MyReconnect), () => conn);
persistentConnections.Add(conn);
});
using (host)
{
using (var connection = CreateConnection("http://foo/endpoint"))
{
var transport = CreateTransport(transportType, host);
var pollEvent = new ManualResetEventSlim();
var reconnectedEvent = new ManualResetEventSlim();
host.OnPoll = () =>
{
pollEvent.Set();
};
connection.Reconnected += () =>
{
reconnectedEvent.Set();
};
connection.Start(transport).Wait();
// Wait for the /poll before restarting the server
Assert.True(pollEvent.Wait(TimeSpan.FromSeconds(15)), "Timed out waiting for poll request");
host.Restart();
Assert.True(reconnectedEvent.Wait(TimeSpan.FromSeconds(15)), "Timed out waiting for client side reconnect");
Assert.Equal(2, persistentConnections.Count);
Assert.Equal(1, persistentConnections[1].Reconnects);
}
}
}
开发者ID:RyanChristensen,项目名称:SignalR,代码行数:51,代码来源:ReconnectFacts.cs
示例13: Initialize
public override void Initialize(int? keepAlive = -1,
int? connectionTimeout = 110,
int? disconnectTimeout = 30,
int? transportConnectTimeout = 5,
bool enableAutoRejoiningGroups = false,
MessageBusType messageBusType = MessageBusType.Default)
{
base.Initialize(keepAlive, connectionTimeout, disconnectTimeout, transportConnectTimeout, enableAutoRejoiningGroups, messageBusType);
_host.Configure(app =>
{
Initializer.ConfigureRoutes(app, Resolver);
});
}
开发者ID:nirmana,项目名称:SignalR,代码行数:14,代码来源:MemoryTestHost.cs
示例14: HubProgressThrowsInvalidOperationExceptionIfAttemptToReportProgressAfterMethodReturn
public async Task HubProgressThrowsInvalidOperationExceptionIfAttemptToReportProgressAfterMethodReturn(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
HubConnection hubConnection = CreateHubConnection(host);
IHubProxy proxy = hubConnection.CreateHubProxy("progress");
proxy.On<bool>("sendProgressAfterMethodReturnResult", result => Assert.True(result));
using (hubConnection)
{
await hubConnection.Start(host.Transport);
await proxy.Invoke<int>("SendProgressAfterMethodReturn", _ => { });
}
}
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:19,代码来源:HubProgressFacts.cs
示例15: TryGetMessageBusType
/// <summary>
/// Gets a message bus type based on the specified string <paramref name="value"/>.
/// </summary>
/// <param name="value">The value to convert to an message bus type (i.e., name, value or unique description).</param>
/// <param name="result">The message bus type.</param>
public static Boolean TryGetMessageBusType(String value, out MessageBusType result)
{
Int32 parsedValue;
Object boxedValue = Int32.TryParse(value, out parsedValue) ? parsedValue : (Object)value;
if (value.IsNullOrWhiteSpace())
{
result = MessageBusType.MicrosoftMessageQueuing;
return true;
}
if (Enum.IsDefined(typeof(MessageBusType), boxedValue))
{
result = (MessageBusType)Enum.ToObject(typeof(MessageBusType), boxedValue);
return true;
}
return KnownMessageBusTypes.TryGetValue(value, out result);
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:24,代码来源:Program.cs
示例16: Initialize
public override void Initialize(int? keepAlive = -1,
int? connectionTimeout = 110,
int? disconnectTimeout = 30,
int? transportConnectTimeout = 5,
int? maxIncomingWebSocketMessageSize = 64 * 1024,
bool enableAutoRejoiningGroups = false,
MessageBusType messageBusType = MessageBusType.Default)
{
base.Initialize(keepAlive,
connectionTimeout,
disconnectTimeout,
transportConnectTimeout,
maxIncomingWebSocketMessageSize,
enableAutoRejoiningGroups,
messageBusType);
_server = WebApp.Start(Url, app =>
{
Initializer.ConfigureRoutes(app, Resolver);
});
}
开发者ID:ZixiangBoy,项目名称:SignalR-1,代码行数:21,代码来源:OwinTestHost.cs
示例17: HubProgressIsReportedSuccessfully
public async Task HubProgressIsReportedSuccessfully(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
HubConnection hubConnection = CreateHubConnection(host);
IHubProxy proxy = hubConnection.CreateHubProxy("progress");
var progressUpdates = new List<int>();
var jobName = "test";
using (hubConnection)
{
await hubConnection.Start(host.Transport);
var result = await proxy.Invoke<string, int>("DoLongRunningJob", progress => progressUpdates.Add(progress), jobName);
Assert.Equal(new[] { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }, progressUpdates);
Assert.Equal(String.Format("{0} done!", jobName), result);
}
}
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:22,代码来源:HubProgressFacts.cs
示例18: TransportTimesOutIfNoInitMessage
public void TransportTimesOutIfNoInitMessage(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
var mre = new ManualResetEventSlim();
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(transportConnectTimeout: 1, messageBusType: messageBusType);
HubConnection hubConnection = CreateHubConnection(host);
IHubProxy proxy = hubConnection.CreateHubProxy("DelayedOnConnectedHub");
using (hubConnection)
{
hubConnection.Start(host.Transport).Catch(ex =>
{
mre.Set();
});
Assert.True(mre.Wait(TimeSpan.FromSeconds(10)));
}
}
}
开发者ID:nirmana,项目名称:SignalR,代码行数:22,代码来源:HubProxyFacts.cs
示例19: ReadingState
public void ReadingState(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
HubConnection connection = CreateHubConnection(host);
using (connection)
{
var hub = connection.CreateHubProxy("demo");
hub["name"] = "test";
connection.Start(host.Transport).Wait();
var result = hub.InvokeWithTimeout<string>("ReadStateValue");
Assert.Equal("test", result);
}
}
}
开发者ID:kabotnik,项目名称:SignalR,代码行数:22,代码来源:HubFacts.cs
示例20: ReadingComplexState
public void ReadingComplexState(HostType hostType, TransportType transportType, MessageBusType messageBusType)
{
using (var host = CreateHost(hostType, transportType))
{
host.Initialize(messageBusType: messageBusType);
var connection = CreateHubConnection(host);
using (connection)
{
var hub = connection.CreateHubProxy("demo");
hub["state"] = JToken.FromObject(new
{
Name = "David",
Address = new
{
Street = "St"
}
});
connection.Start(host.Transport).Wait();
var result = hub.InvokeWithTimeout<dynamic>("ReadAnyState");
dynamic state2 = hub["state2"];
dynamic addy = hub["addy"];
Assert.NotNull(result);
Assert.NotNull(state2);
Assert.NotNull(addy);
Assert.Equal("David", (string)result.Name);
Assert.Equal("St", (string)result.Address.Street);
Assert.Equal("David", (string)state2.Name);
Assert.Equal("St", (string)state2.Address.Street);
Assert.Equal("St", (string)addy.Street);
}
}
}
开发者ID:kabotnik,项目名称:SignalR,代码行数:38,代码来源:HubFacts.cs
注:本文中的MessageBusType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论