private void btnConnectToLs_Click(object sender, EventArgs e) { try { lblConnecionStatus.Text = ""; LSClient.SetLoggerProvider(new Log4NetLoggerProviderWrapper()); string pushServerHost = txtboxLsServer.Text; int pushServerPort = Convert.ToInt32(txtLsPort.Text); ConnectionInfo connInfo = new ConnectionInfo(); connInfo.PushServerUrl = "http://" + pushServerHost + ":" + pushServerPort; connInfo.Adapter = txtboxAdapterSetName.Text; connInfo.User = txtboxUserName.Text; connInfo.Password = txtboxPassword.Text; myClient = new LSClient(); myClient.OpenConnection(connInfo, new LsConnectionListener(lblConnecionStatus)); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
public void Initialize() { m_lsClient = new LSClient(); ReceivedFeedBCollecion = new BlockingCollection <FeedMessage>(); m_dsSchema = new dsSchema(); m_TableListenerForExtended = new TableListenerForExtended(m_ReceivedFeedBCollecion, m_dsSchema); }
static void Main(string[] args) { Console.Title = "YGCore GameServer"; Console.WriteLine("Authors: Jenose\n" + "Authorized representative: netgame.in.th\n\n" + "-------------------------------------------\n"); Stopwatch sw = Stopwatch.StartNew(); Opcode.Init(); Configuration.GetInstance(); Data.LoadAll(); StatsService.GetInstance(); ClientManager.GetInstance(); LSClient.GetInstance(); foreach (var channel in Configuration.GetInstance().Channels) { NetworkFactory.NewInstance(channel.Port); } sw.Stop(); Thread.Sleep(100); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); Process.GetCurrentProcess().WaitForExit(); }
// Use this for initialization void Start() { if (client == null) { client = new LSClient(); Debug.Log("LSClient initialized!"); try { var th = new Thread(LightStreanerConnect); th.Start(); } catch (SystemException se) { Debug.LogError("Unexpected error: " + se.Message); } } nextUpdate = Queue.Synchronized(nextUpdate); // Only for development. System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true; Debug.Log("Goooooooodmorning Lightstreamer ... "); Component i = GetComponent <Component>(); Component[] Children = i.GetComponentsInChildren(typeof(Renderer)); foreach (Component child in Children) { //child is your child transform Debug.Log("My child: " + child.tag); if (child.tag.StartsWith("lightstreamer")) { LightstreamerAsset ls = child.GetComponent(typeof(LightstreamerAsset)) as LightstreamerAsset; if (ls != null) { Debug.Log("My child: " + ls.ItemName); // Add info for a subscription ExtendedTableInfo tableInfo = new ExtendedTableInfo( ls.ItemName.Split(','), "MERGE", ls.Schema.Split(','), true) { DataAdapter = ls.DataAdapter }; subscriptionsLS.Enqueue(tableInfo); ls.addSender(this); } } } }
public IGStreamingApiClient() { try { lsClient = new LSClient(); } catch (Exception) { } }
public IGMarketDataStreamer(AccountDetails accountDetails, IGApiAccount account) { Client = new LSClient(); ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.User = accountDetails.Accounts[0].AccountId; connectionInfo.Password = $"CST-{account.CST}|XST-{account.XSecurityToken}"; connectionInfo.PushServerUrl = accountDetails.LightstreamerEndpoint; Client.OpenConnection(connectionInfo, new ClientConnectionEvents()); CreateSubscription("IX.D.OMX.IFM.IP"); }
/// <summary> /// /// </summary> /// <param name="streamingUri"></param> /// <param name="userName"></param> /// <param name="sessionId"></param> /// <param name="adapterSet"></param> /// <param name="usePolling"></param> /// <param name="serializer"></param> public FaultTolerantLsClientAdapter(string streamingUri, string userName, string sessionId, string adapterSet, bool usePolling, IJsonSerializer serializer) { #if !SILVERLIGHT //Ensure that at least another 2 concurrent HTTP connections are allowed by the desktop .NET framework //(it defaults to 2, which will already be used if there is another LSClient active) ServicePointManager.DefaultConnectionLimit += 2; #endif _usePolling = usePolling; _serializer = serializer; _adapterSet = adapterSet; _streamingUri = streamingUri; _sessionId = sessionId; _userName = userName; _client = new LSClient(); }
public LightstreamerClient( IRtdLightstreamerListener listener, string adapter_set, string adapter_name, FlowForm flowForm) { if (listener == null) { throw new ArgumentNullException("listener is null"); } this.adapter_set = adapter_set; this.adapter_name = adapter_name; this.listener = listener; this.flowForm = flowForm; client = new LSClient(); }
public StocklistClient( string pushServerUrl, DemoForm form, LightstreamerUpdateDelegate lsUpdateDelegate, LightstreamerStatusChangedDelegate lsStatusChangeDelegate) { demoForm = form; updateDelegate = lsUpdateDelegate; statusChangeDelegate = lsStatusChangeDelegate; cInfo = new ConnectionInfo(); cInfo.PushServerUrl = pushServerUrl; cInfo.Adapter = "DEMO"; client = new LSClient(); }
public LightstreamerAdapter(ILogger logger, IJsonSerializer serializer, string streamingUri, string userName, string password, string adapterSet, bool usePolling) { ServicePointManager.DefaultConnectionLimit += 2; _client = new LSClient(); _logger = logger; _serializer = serializer; _streamingUri = streamingUri; _userName = userName; _password = password; _adapterSet = adapterSet; _usePolling = usePolling; }
public void CreateConnection() { try { lsClient = new LSClient(); connectionInfo = new ConnectionInfo(); connectionInfo.Adapter = "DEFAULT"; connectionInfo.User = Session.Username; connectionInfo.Password = string.Format("CST-{0}|XST-{1}", Session.CST, Session.X_SECURITY_TOKEN); connectionInfo.PushServerUrl = Session.Response.Response.LightstreamerEndpoint; lsClient.OpenConnection(connectionInfo, this); ConnectionEstablished = true; } catch (Exception ex) { Console.WriteLine("LS Connection Failed"); ConnectionEstablished = false; } }
/// <summary> /// Opens a connection, performs a table subscription and unsubscription /// and closes the connection after some time. /// </summary> /// <param name="args">Should specify the host name of the Server, the port number /// and optionally the "extended", "multiple" and "command" flags. /// </param> /// <throws>Exception Thrown in case of any error.</throws> public static void Main(string[] args) { LSClient.SetLoggerProvider(new Log4NetLoggerProviderWrapper()); string pushServerHost = args[0]; int pushServerPort = Int32.Parse(args[1]); ArrayList opts = new ArrayList(); for (int i = 2; i < args.Length; i++) { opts.Add(args[i]); } bool extended = opts.Contains("extended"); bool multiple = opts.Contains("multiple"); bool command = opts.Contains("command"); Thread.Sleep(2000); ConnectionInfo connInfo = new ConnectionInfo(); connInfo.PushServerUrl = "http://" + pushServerHost + ":" + pushServerPort; connInfo.Adapter = "DEMO"; LSClient myClient = new LSClient(); myClient.OpenConnection(connInfo, new TestConnectionListener()); Thread.Sleep(5000); ArrayList refs = new ArrayList(); SubscribedTableKey[] tableRefs; if (!command) { if (extended) { ExtendedTableInfo tableInfo = new ExtendedTableInfo( new string[] { "item1", "item2", "item3" }, "MERGE", new string[] { "last_price", "time", "pct_change" }, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestTableListenerForExtended(), false ); tableRefs = new SubscribedTableKey[] { tableRef }; } else if (multiple) { ExtendedTableInfo tableInfo = new ExtendedTableInfo( new string[] { "item1", "item2", "item3" }, "MERGE", new string[] { "last_price", "time", "pct_change" }, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; tableRefs = myClient.SubscribeItems( tableInfo, new TestTableListenerForMultiple() ); } else { // Group and Schema names have to be manageable by // the LiteralBasedProvider used for the StockListDemo string groupName = "item1 item2 item3"; string schemaName = "last_price time pct_change"; SimpleTableInfo tableInfo = new SimpleTableInfo( groupName, "MERGE", schemaName, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestTableListenerForSimple(), false ); tableRefs = new SubscribedTableKey[] { tableRef }; } } else { if (extended) { ExtendedTableInfo tableInfo = new ExtendedTableInfo( new String[] { "portfolio1" }, "COMMAND", new String[] { "key", "command", "qty" }, true ); tableInfo.DataAdapter = "PORTFOLIO_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestPortfolioListenerForExtended(), true ); tableRefs = new SubscribedTableKey[] { tableRef }; } else { // Group and Schema names have to be manageable by // the LiteralBasedProvider used for the StockListDemo String groupName = "portfolio1"; String schemaName = "key command qty"; SimpleTableInfo tableInfo = new SimpleTableInfo( groupName, "COMMAND", schemaName, true ); tableInfo.DataAdapter = "PORTFOLIO_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestPortfolioListenerForSimple(), true ); tableRefs = new SubscribedTableKey[] { tableRef }; } } for (int j = 0; j < tableRefs.Length; j++) { refs.Add(tableRefs[j]); } Thread.Sleep(20000); SubscribedTableKey[] allTableRefs = new SubscribedTableKey[refs.Count]; for (int i = 0; i < refs.Count; i++) { allTableRefs[i] = (SubscribedTableKey)refs[i]; } myClient.UnsubscribeTables(allTableRefs); Thread.Sleep(5000); myClient.CloseConnection(); Thread.Sleep(2000); Environment.Exit(0); }
// ReSharper restore FieldCanBeMadeReadOnly.Local static LightstreamerClient() { LSClient.SetLoggerProvider(new LSLoggerProvider()); }
/// <summary> /// Opens a connection, performs a table subscription and unsubscription /// and closes the connection after some time. /// </summary> /// <param name="args">Should specify the host name of the Server, the port number /// and optionally the "extended", "multiple" and "command" flags. /// </param> /// <throws>Exception Thrown in case of any error.</throws> public static void Main(string[] args) { LSClient.SetLoggerProvider(new Log4NetLoggerProviderWrapper()); string pushServerHost = args[0]; int pushServerPort = Int32.Parse(args[1]); ArrayList opts = new ArrayList(); for (int i = 2; i < args.Length; i++) { opts.Add(args[i]); } bool extended = opts.Contains("extended"); bool multiple = opts.Contains("multiple"); bool command = opts.Contains("command"); Thread.Sleep(2000); ConnectionInfo connInfo= new ConnectionInfo(); connInfo.PushServerUrl= "http://" + pushServerHost + ":" + pushServerPort; connInfo.Adapter= "DEMO"; LSClient myClient = new LSClient(); myClient.OpenConnection(connInfo, new TestConnectionListener()); Thread.Sleep(5000); ArrayList refs = new ArrayList(); SubscribedTableKey[] tableRefs; if (!command) { if (extended) { ExtendedTableInfo tableInfo= new ExtendedTableInfo( new string[] { "item1", "item2", "item3" }, "MERGE", new string[] { "last_price", "time", "pct_change" }, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestTableListenerForExtended(), false ); tableRefs = new SubscribedTableKey[] { tableRef }; } else if (multiple) { ExtendedTableInfo tableInfo= new ExtendedTableInfo( new string[] { "item1", "item2", "item3" }, "MERGE", new string[] { "last_price", "time", "pct_change" }, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; tableRefs = myClient.SubscribeItems( tableInfo, new TestTableListenerForMultiple() ); } else { // Group and Schema names have to be manageable by // the LiteralBasedProvider used for the StockListDemo string groupName = "item1 item2 item3"; string schemaName = "last_price time pct_change"; SimpleTableInfo tableInfo= new SimpleTableInfo( groupName, "MERGE", schemaName, true ); tableInfo.DataAdapter = "QUOTE_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestTableListenerForSimple(), false ); tableRefs = new SubscribedTableKey[] { tableRef }; } } else { if (extended) { ExtendedTableInfo tableInfo = new ExtendedTableInfo( new String[] { "portfolio1" }, "COMMAND", new String[] { "key", "command", "qty" }, true ); tableInfo.DataAdapter = "PORTFOLIO_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestPortfolioListenerForExtended(), true ); tableRefs = new SubscribedTableKey[] { tableRef }; } else { // Group and Schema names have to be manageable by // the LiteralBasedProvider used for the StockListDemo String groupName = "portfolio1"; String schemaName = "key command qty"; SimpleTableInfo tableInfo = new SimpleTableInfo( groupName, "COMMAND", schemaName, true ); tableInfo.DataAdapter = "PORTFOLIO_ADAPTER"; SubscribedTableKey tableRef = myClient.SubscribeTable( tableInfo, new TestPortfolioListenerForSimple(), true ); tableRefs = new SubscribedTableKey[] { tableRef }; } } for (int j = 0; j < tableRefs.Length; j++) { refs.Add(tableRefs[j]); } Thread.Sleep(20000); SubscribedTableKey[] allTableRefs = new SubscribedTableKey[refs.Count]; for (int i= 0; i < refs.Count; i++) allTableRefs[i]= (SubscribedTableKey) refs[i]; myClient.UnsubscribeTables(allTableRefs); Thread.Sleep(5000); myClient.CloseConnection(); Thread.Sleep(2000); Environment.Exit(0); }
private async void okTestButton_Click(object sender, EventArgs e) { if (isConnectionTested) { // add connection to file and close if (editingInfo != null) { if (nameInput.Text != editingInfo.ConnectionName && ConnectionsDAL.ConnectionExists(nameInput.Text)) { MessageBox.Show( $"A connection with the name \"{nameInput.Text}\" " + "already exists." + Environment.NewLine + "Please select another name.", "Connection rejected", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { ConnectionsDAL.EditConnection( editingInfo, nameInput.Text, ipInput.Text); } } else { ConnectionsDAL.TryAddConnection(new ConnectionInfo(nameInput.Text, ipInput.Text)); } DialogResult = DialogResult.OK; } else { string ipString = ipInput.Text; // test connection if (ipString.IsIPv4Format() && IPAddress.TryParse(ipString, out IPAddress ip)) { okTestButton.Enabled = false; cancelButton.Enabled = false; connectionResultLabel.Text = "Connecting..."; LSClient testClient = new LSClient(); if (await testClient.TryConnectAsync(ip, 1337)) { // connection successful testClient.Close(); isConnectionTested = true; okTestButton.Text = "OK"; connectionResultLabel.Text = "Connected!"; } else { connectionResultLabel.Text = "Connection failed"; } okTestButton.Enabled = true; cancelButton.Enabled = true; } else { // invalid IP connectionResultLabel.Text = "Invalid IP"; } } }
public LightstreamerClient(string[] items, string[] fields) { this.items = items; this.fields = fields; client = new LSClient(); }
public LightstreamerClient() { client = new LSClient(); }