// [Ignore("Adhoc Integration Test"), Test] public async Task Try_connect_to_ServerEvents_over_proxy() { ServerEventsClient client = null; var proxyBaseUrl = ListeningOn.CombineWith("chat"); client = new ServerEventsClient(proxyBaseUrl) { OnConnect = async c => { var proxyUrl = ListeningOn + c.HeartbeatUrl.Replace("http://chat.servicestack.net", "chat"); client.ConnectionInfo.HeartbeatIntervalMs = 1000; client.ConnectionInfo.HeartbeatUrl = proxyUrl; var response = await proxyUrl.GetStringFromUrlAsync(); Assert.That(response, Is.Empty); }, OnHeartbeat = () => { "Received Heartbeat".Print(); }, OnException = ex => { ex.Message.Print(); } }; client.Start(); await client.Connect(); Thread.Sleep(TimeSpan.FromSeconds(120)); }
protected override void OnPostCreate(Bundle savedInstanceState) { base.OnPostCreate(savedInstanceState); this.UpdateCookiesFromIntent(client); drawerToggle.SyncState(); UiHelpers.ResetChannelDrawer(this, navigationView, client.Channels); client.Connect().ConfigureAwait(false); }
public async Task Does_dispose_SSE_Connection_when_Exception_in_OnInit_handler() { ServerEventsClient client = null; using (client = new ServerEventsClient(Config.AbsoluteBaseUri) { // OnException = e => client.Dispose() }) { try { await client.Connect(); } catch (WebException e) { Assert.That(e.GetStatus(), Is.EqualTo(HttpStatusCode.InternalServerError)); } } }
public async Task Does_reconnect_when_remote_AppServer_restarts() { var client = new ServerEventsClient("http://localhost:11001", "home") { OnConnect = ctx => "OnConnect: {0}".Print(ctx.Channel), OnCommand = msg => "OnCommand: {0}".Print(msg.Data), OnException = ex => "OnException: {0}".Print(ex.Message), OnMessage = msg => "OnMessage: {0}".Print(msg.Data), OnHeartbeat = () => "OnHeartbeat".Print() }; client.Handlers["chat"] = (source, msg) => { "Received Chat: {0}".Print(msg.Data); }; await client.Connect(); await Task.Delay(TimeSpan.FromMinutes(10)); }