Here’s the code I’m using in a wpf app to test the embedded EventStore and client.
It all works perfectly. I was unable to “see” the eventstore by directing my browser to “http://localhost:2113”, instead seeing a “localhost refused to connect” message.
Should I be able to view the embedded eventstore from the browser? If not, is there a way to enable it?
using EventStore.ClientAPI;
using EventStore.ClientAPI.Embedded;
using EventStore.Core.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp1 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
Task.Run(DoStuff);
}
async Task DoStuff() {
if (Debugger.IsAttached)
Console.SetOut(new DebugWriter());
var started = new TaskCompletionSource<object>();
var node = EmbeddedVNodeBuilder.AsSingleNode()
.OnDefaultEndpoints()
.RunInMemory()
.Build();
var connection = EmbeddedEventStoreConnection.Create(node);
await connection.ConnectAsync();
await connection.AppendToStreamAsync("testStream", EventStore.ClientAPI.ExpectedVersion.Any,
new EventData(Guid.NewGuid(), "eventType", true,
Encoding.UTF8.GetBytes("{\"Foo\":\"Bar\"}"), null));
var events = await connection.ReadStreamEventsForwardAsync("testStream", 0, 1024, true, new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"));
Console.WriteLine(JsonConvert.SerializeObject(connection.Settings));
Console.Beep(1000, 50);
while(true) {
await Task.Delay(1000);
}
}
}
class DebugWriter : TextWriter {
public override void WriteLine(string value) {
Debug.WriteLine(value);
base.WriteLine(value);
}
public override void Write(string value) {
Debug.Write(value);
base.Write(value);
}
public override Encoding Encoding {
get { return Encoding.Unicode; }
}
}
}
``