Exemplo n.º 1
0
        /// <summary>
        /// account details subscription
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="tableListener"></param>

        public void subscribeToAccountDetails(string accountId, IHandyTableListener tableListener, string[] fields)
        {
            ExtendedTableInfo extTableInfo = new ExtendedTableInfo(
                new string[] { "ACCOUNT:" + accountId },
                "MERGE",
                fields,
                true
                );
            SubscribedTableKey tableKey = lsClient.SubscribeTable(extTableInfo, tableListener, false);
        }
        public SubscribedTableKey SubscribeToAccountDetails(string accountId, IHandyTableListener tableListener, IEnumerable <string> fields)
        {
            ExtendedTableInfo extTableInfo = new ExtendedTableInfo(
                new[] { "ACCOUNT:" + accountId },
                "MERGE",
                fields.ToArray(),
                true
                );

            return(lsClient.SubscribeTable(extTableInfo, tableListener, false));
        }
Exemplo n.º 3
0
        public SubscribedTableKey SubscribeToIndexMarketData(IHandyTableListener iHandyTableListener, String Epic)
        {
            if (ConnectionEstablished == false)
            {
                throw new Exception();
            }

            String Trade = "MARKET:" + Epic;

            String[] Items  = new String[] { Trade };
            String[] Fields = new string[] { "BID", "OFFER", "UPDATE_TIME" };

            ExtendedTableInfo extendedTableInfo = new ExtendedTableInfo(Items, "MERGE", Fields, true);

            return(lsClient.SubscribeTable(extendedTableInfo, iHandyTableListener, false));
        }
Exemplo n.º 4
0
        private void btnSubscribeToLs_Click(object sender, EventArgs e)
        {
            try
            {
                SubscribedTableKey[] tableRefs;


                string items = txtBoxSubsciptionItems.Text;
                subsciptionmdoe = comboBoxSubscriptionMode.Text;
                schecmName      = textboxSchema.Text;



                DialogResult dialogresult = MessageBox.Show("Subscribe to items : " + items, "Subscription", MessageBoxButtons.YesNo);

                if (dialogresult == DialogResult.No)
                {
                    return;
                }

                SimpleTableInfo tableInfo = new SimpleTableInfo(
                    items,
                    subsciptionmdoe,
                    schecmName,
                    false
                    );

                tableInfo.DataAdapter = txtboxFeedAdatperName.Text;



                SubscribedTableKey tableRef = myClient.SubscribeTable(
                    tableInfo,
                    new TableListenerForExtended(m_ReceivedFeedBCollecion),
                    false
                    );


                tableRefs = new SubscribedTableKey[] { tableRef };
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.ToString());
            }
        }
        public void AddSubcribe(string[] items, string[] fields)
        {
            SimpleTableInfo tableInfo = new ExtendedTableInfo(
                items, "MERGE", fields, true);

            tableInfo.DataAdapter = this.adapter_name;

            tableKey = client.SubscribeTable(tableInfo,
                                             new StocklistHandyTableListener(listener), false);
        }
Exemplo n.º 6
0
        public void Subscribe(int phase, ILightstreamerListener listener)
        {
            StocklistHandyTableListener hl = new StocklistHandyTableListener(listener, phase);

            SimpleTableInfo tableInfo = new ExtendedTableInfo(
                items, "MERGE", fields, true);

            tableInfo.DataAdapter = "QUOTE_ADAPTER";
            client.SubscribeTable(tableInfo, hl, false);
        }
Exemplo n.º 7
0
        private void Subscribe()
        {
            lock (this)
            {
                this.syncContext.Send(this.cleanModel, "");

                //this method will try just one subscription.
                //we know that when this method executes we should be already connected
                //If we're not or we disconnect while subscribing we don't have to do anything here as an
                //event will be (or was) sent to the ConnectionListener that will handle the case.
                //If we're connected but the subscription fails we can't do anything as the same subscription
                //would fail again and again (btw this should never happen)

                try
                {
                    ExtendedTableInfo tableInfo = new ExtendedTableInfo(
                        new string[] { "item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8", "item9", "item10", "item11", "item12", "item13", "item14", "item15", "item16", "item17", "item18", "item19", "item20", "item21", "item22", "item23", "item24", "item25", "item26", "item27", "item28", "item29", "item30" },
                        "MERGE",
                        new string[] { "stock_name", "last_price", "time", "pct_change", "bid_quantity", "bid", "ask", "ask_quantity", "min", "max", "ref_price", "open_price" },
                        true);
                    tableInfo.DataAdapter = "QUOTE_ADAPTER";

                    client.SubscribeTable(
                        tableInfo,
                        new StocklistHandyTableListener(this, this.phase, gridModel),
                        false);
                }
                catch (SubscrException e)
                {
                    this.StatusChanged(this.phase, "No session is active: " + e.Message, null);
                }
                catch (PushServerException e)
                {
                    this.StatusChanged(this.phase, "Unexpected error: " + e.Message, null);
                }
                catch (PushUserException e)
                {
                    this.StatusChanged(this.phase, "Request refused: " + e.Message, null);
                }
                catch (PushConnException e)
                {
                    this.StatusChanged(this.phase, "Control connection failed: " + e.Message, null);
                }
            }
        }
Exemplo n.º 8
0
        private void subscribe()
        {
            lock (this)
            {
                //this method will try just one subscription.
                //we know that when this method executes we should be already connected
                //If we're not or we disconnect while subscribing we don't have to do anything here as an
                //event will be (or was) sent to the ConnectionListener that will handle the case.
                //If we're connected but the subscription fails we can't do anything as the same subscription
                //would fail again and again (btw this should never happen)

                try
                {
                    SimpleTableInfo tableInfo = new SimpleTableInfo(
                        "item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 item11 item12 item13 item14 item15 item16 item17 item18 item19 item20 item21 item22 item23 item24 item25 item26 item27 item28 item29 item30",
                        "MERGE",
                        "stock_name last_price time pct_change bid_quantity bid ask ask_quantity min max ref_price open_price",
                        true);
                    tableInfo.DataAdapter = "QUOTE_ADAPTER";

                    client.SubscribeTable(
                        tableInfo,
                        new StocklistHandyTableListener(this, this.phase),
                        false);
                }
                catch (SubscrException)
                {
                }
                catch (PushServerException)
                {
                }
                catch (PushUserException)
                {
                }
                catch (PushConnException)
                {
                }
            }
        }
        /// <summary>
        /// Subscirbe in lightstreamer
        /// server to Get item feed
        /// </summary>
        /// <param name="Item"></param>
        /// <param name="SchemaCode"></param>
        public void Subscibe(string Item, string Mode)
        {
            List <string> items = new List <string>();

            items.Add(Item);

            string            schema    = GetSchema(Item);
            ExtendedTableInfo tableInfo = new ExtendedTableInfo(
                items.ToArray(),
                Mode,
                schema.Split(new char[] { ' ' }),
                true
                );

            tableInfo.DataAdapter = FeedAdapter;

            NotificaionTableRef = m_lsClient.SubscribeTable(
                tableInfo,
                m_TableListenerForExtended,
                false
                );
        }
    public SubscribedTableKey AppendListener(ILightstreamerListener listener, string[] items, string[] fields)
    {
        SubscribedTableKey tableKey = null;

        if (listener == null)
        {
            throw new ArgumentNullException("listener is null");
        }
        if (ls != null)
        {
            ls.AppendListener(listener);
        }
        if (hl != null)
        {
            hl.AppendListener(listener);

            SimpleTableInfo tableInfo = new ExtendedTableInfo(
                items, "MERGE", fields, true);
            tableInfo.DataAdapter = "QUOTE_ADAPTER";
            tableKey = client.SubscribeTable(tableInfo, hl, false);
        }

        return(tableKey);
    }
Exemplo n.º 11
0
 public SubscribedTableKey SubscribeTable <TDto>(SimpleTableInfo simpleTableInfo, ITableListener <TDto> listener, bool b) where TDto : class, new()
 {
     return(_client.SubscribeTable(simpleTableInfo, listener, b));
 }
Exemplo n.º 12
0
        /// <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);
        }
Exemplo n.º 13
0
        /// <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);
        }
    // Update is called once per frame
    void Update()
    {
        if (this.StateMachine == 0)
        {
            this.StateMachine = 1;
        }
        else if (this.StateMachine == 1)
        {
            if (goFlag)
            {
                this.StateMachine = 2;
            }
        }
        else if (this.StateMachine == 2)
        {
            this.StateMachine = 3;
            if (subscriptionsLS.Count > 0)
            {
                Debug.Log("Subscribing ...");

                ExtendedTableInfo tab = this.subscriptionsLS.Dequeue() as ExtendedTableInfo;
                while (tab != null)
                {
                    client.SubscribeTable(
                        tab,
                        new StocklistHandyTableListener(this),
                        false);

                    Debug.Log("Subscribe " + tab.DataAdapter);

                    if (subscriptionsLS.Count > 0)
                    {
                        tab = this.subscriptionsLS.Dequeue() as ExtendedTableInfo;
                    }
                    else
                    {
                        tab = null;
                    }
                }

                if (!goFlag)
                {
                    goFlag = true;
                }
            }
        }
        else if (this.StateMachine == 2001)
        {
            while (this.nextUpdate.Count != 0)
            {
                Debug.Log("SendMessage Update.");
                BroadcastMessage("RTUpdates", (IUpdateInfo)this.nextUpdate.Dequeue());
            }

            this.StateMachine = 3;
        }
        else if (this.StateMachine == 2010)
        {
            if (this.nextStatus != null)
            {
                Debug.Log("SendMessage Status: " + this.nextStatus);
                BroadcastMessage("RTStatus", this.nextStatus);
            }
            this.nextStatus   = null;
            this.StateMachine = 3;
        }
    }