plugin re render
Created at 09 Jan 2025, 09:25
plugin re render
09 Jan 2025, 09:25
Hi,
I have a React.js Chat app, integrated into a cTrader plugin using a WebView.
Problem:
The app is repeatedly sending the same message to the chat for no obvious reason.
The app works perfectly in a browser.
code:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo.Plugins
{
[Plugin(AccessRights = AccessRights.None)]
public class LocalhostViewer : Plugin
{
private WebView _webView;
private string baseUrl = "http://localhost:3000";
private string clientName = "plaseHolder";
private string accountName;
private string fullUrl;
protected override void OnStart()
{
accountName = Account.Number.ToString();
fullUrl = $"{baseUrl}?client_token={clientName}&userId={accountName}";
_webView = new WebView();
_webView.Loaded += OnWebViewLoaded;
var customFrame = ChartManager.AddCustomFrame("Localhost Viewer");
customFrame.Child = _webView;
customFrame.ChartContainer.Mode = ChartMode.Multi;
customFrame.Attach();
}
private void OnWebViewLoaded(WebViewLoadedEventArgs args)
{
_webView.NavigateAsync(fullUrl);
}
protected override void OnStop()
{
Print("Plugin stopped.");
}
}
}
Thanks!
Moshe