static async Task Main(string[] args) { ReduxConnection reduxConnection = new ReduxConnection("CheckMate", SocketOptions.Default); CancellationToken cancellationToken = CancellationToken.None; await reduxConnection.ConnectAsync(cancellationToken); CheckMateState state = new CheckMateState(); reduxConnection.UpdateState(state, "Setup"); int count = 0; while (!cancellationToken.IsCancellationRequested) { count++; if (count % 2 == 0) { state.ChangelistCount++; } else { state.Server = $"Server {Guid.NewGuid():D}"; } reduxConnection.UpdateState(state, "Update Loop"); await Task.Delay(5000); } reduxConnection.Disconnect(); }
public async Task InvokeAsync(IActionContext <T> actionContext) { if (actionContext.Action is InitializeAction) { await m_connection.ConnectAsync(CancellationToken.None); m_connection.InitState(actionContext.Store.GetState(), ""); m_connection.SetDispatch(actionContext.Store.Dispatch); } await m_next(actionContext); // We are connected and we are not the base action if (m_connection.IsConnected && !(actionContext.Action is BaseAction)) { m_connection.UpdateState(actionContext.Result, actionContext.Action.Type); } }