Summary
Server related information.
Syntax
public interface IServer
Members
Name | Type | Summary |
---|---|---|
Connected | Event | Event raised when successfully connected with the server |
Disconnected | Event | Disconnected - Event raised when connection with the server is lost |
IsConnected | Property | Indicates current connection status with the server |
Time | Property | Returns the server time. |
TimeInUtc | Property | Returns the server time in UTC. |
Example 1
using cAlgo.API; namespace cAlgo { // This sample indicator shows how to use Server object to get data related to server and connection [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class ServerSample : Indicator { private TextBlock _isConnectedTextBlock; protected override void Initialize() { var grid = new Grid(4, 2) { BackgroundColor = Color.Gold, Opacity = 0.6, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; var style = new Style(); style.Set(ControlProperty.Padding, 5); style.Set(ControlProperty.Margin, 5); style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold); style.Set(ControlProperty.BackgroundColor, Color.Black); grid.AddChild(new TextBlock { Text = "Server Info", Style = style, HorizontalAlignment = HorizontalAlignment.Center }, 0, 0, 1, 2); grid.AddChild(new TextBlock { Text = "Time", Style = style }, 1, 0); grid.AddChild(new TextBlock { Text = Server.Time.ToString("o"), Style = style }, 1, 1); grid.AddChild(new TextBlock { Text = "Time (UTC)", Style = style }, 2, 0); grid.AddChild(new TextBlock { Text = Server.TimeInUtc.ToString("o"), Style = style }, 2, 1); grid.AddChild(new TextBlock { Text = "Is Connected", Style = style }, 3, 0); _isConnectedTextBlock = new TextBlock { Text = Server.IsConnected ? "Yes" : "No", Style = style, }; Server.Connected += () => _isConnectedTextBlock.Text = "Yes"; Server.Disconnected += () => _isConnectedTextBlock.Text = "No"; grid.AddChild(_isConnectedTextBlock, 3, 1); Chart.AddControl(grid); } public override void Calculate(int index) { } } }