Пример #1
0
        internal virtual StreamReader GetNotBatchedAnswer(string controlUrl, Hashtable parameters)
        {
            HttpProvider provider = new HttpProvider(controlUrl);

            protLogger.Info("Opening control connection");
            if (protLogger.IsDebugEnabled)
            {
                protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters));
            }
            return(new StreamReader(provider.DoPost(parameters), Encoding.Default));
        }
        internal virtual Stream CallResync(PushServerProxy.PushServerProxyInfo pushInfo, Lightstreamer.DotNet.Client.ConnectionConstraints newConstraints)
        {
            Hashtable parameters = new Hashtable();

            parameters["LS_session"] = pushInfo.sessionId;
            if (newConstraints != null)
            {
                this.info.constraints = (Lightstreamer.DotNet.Client.ConnectionConstraints)newConstraints.Clone();
            }
            AddConnectionProperties(parameters, this.info);
            AddConstraints(parameters, this.info.constraints);
            HttpProvider provider = new HttpProvider(pushInfo.rebindAddress + "/lightstreamer/bind_session.txt");

            protLogger.Info("Opening stream connection to rebind current session");
            if (protLogger.IsDebugEnabled)
            {
                protLogger.Debug("Rebinding params: " + CollectionsSupport.ToString(parameters));
            }
            return(provider.DoPost(parameters));
        }
Пример #3
0
 internal virtual ITableManager[] Close()
 {
     ITableManager[] managerArray;
     lock (this.tables.SyncRoot)
     {
         managerArray = (ITableManager[])CollectionsSupport.ToArray(this.tables.Values, new ITableManager[0]);
         this.tables.Clear();
     }
     sessionLogger.Info("Terminating session " + this.localPushServerProxy.SessionId);
     this.localPushServerProxy.Dispose();
     this.CloseBatch();
     if (actionsLogger.IsInfoEnabled)
     {
         for (int i = 0; i < managerArray.Length; i++)
         {
             actionsLogger.Info(string.Concat(new object[] { "Discarded ", managerArray[i], " from session ", this.localPushServerProxy.SessionId }));
         }
     }
     return(managerArray);
 }
        internal virtual Stream CallSession()
        {
            Stream    stream;
            Hashtable parameters = new Hashtable();

            if (this.info.user != null)
            {
                parameters["LS_user"] = this.info.user;
            }
            if (this.info.password != null)
            {
                parameters["LS_password"] = this.info.password;
            }
            if (this.info.adapter != null)
            {
                parameters["LS_adapter"] = this.info.adapter;
            }
            AddConnectionProperties(parameters, this.info);
            AddConstraints(parameters, this.info.constraints);
            HttpProvider provider = new HttpProvider(this.info.pushServerUrl + "/lightstreamer/create_session.txt");

            protLogger.Info("Opening stream connection");
            if (protLogger.IsDebugEnabled)
            {
                protLogger.Debug("Connection params: " + CollectionsSupport.ToString(parameters));
            }
            try
            {
                stream = provider.DoPost(parameters);
            }
            catch (UriFormatException exception)
            {
                throw exception;
            }
            catch (WebException exception2)
            {
                throw exception2;
            }
            return(stream);
        }
 public virtual void NotifyUnsub()
 {
     ItemInfo[] objects = new ItemInfo[this.itemInfos.Count];
     lock (this.itemInfos)
     {
         objects           = (ItemInfo[])CollectionsSupport.ToArray(this.itemInfos, objects);
         this.unsubscrDone = true;
     }
     for (int i = 0; i < objects.Length; i++)
     {
         if (objects[i] != null)
         {
             this.NotifyUnsubForItem(objects[i].pos, objects[i].name);
         }
     }
     try
     {
         this.listener.OnUnsubscrAll();
     }
     catch (Exception)
     {
     }
 }
Пример #6
0
 private static void ProcessFastUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values, int itemIndex, ExtendedTableInfo table, IFastItemsListener listener)
 {
     if (values.EOS)
     {
         try
         {
             listener.OnSnapshotEnd(itemIndex + 1);
         }
         catch (Exception)
         {
         }
     }
     else if (values.Overflow > 0)
     {
         if (!table.hasUnfilteredData())
         {
             throw new PushServerException(7);
         }
         try
         {
             listener.OnRawUpdatesLost(itemIndex + 1, values.Overflow);
         }
         catch (Exception)
         {
         }
     }
     else
     {
         if (values.Size != table.fields.Length)
         {
             throw new PushServerException(3);
         }
         string[] array = values.Array;
         if (actionsLogger.IsDebugEnabled)
         {
             actionsLogger.Debug("Got event for item " + table.items[itemIndex] + " with values " + CollectionsSupport.ToString(array) + " for fields " + CollectionsSupport.ToString(table.fields));
         }
         try
         {
             listener.OnUpdate(itemIndex + 1, array);
         }
         catch (Exception)
         {
         }
     }
 }
        internal void ProcessUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values, int itemPos, int itemIndex)
        {
            string   name = null;
            ItemInfo info;

            if (this.extInfo != null)
            {
                if ((itemIndex < 0) || (itemIndex >= this.extInfo.items.Length))
                {
                    throw new PushServerException(2);
                }
                name = this.extInfo.items[itemIndex];
            }
            lock (this.itemInfos)
            {
                if (this.unsubscrDone)
                {
                    return;
                }
                while (this.itemInfos.Count <= itemIndex)
                {
                    this.itemInfos.Add(null);
                }
                info = (ItemInfo)this.itemInfos[itemIndex];
                if (info == null)
                {
                    if (this.isCommandLogic)
                    {
                        info = new CommandLogicItemInfo(this, itemPos, name);
                    }
                    else
                    {
                        info = new ItemInfo(this, itemPos, name);
                    }
                    this.itemInfos[itemIndex] = info;
                }
            }
            if (values.EOS)
            {
                info.snapshotPending = false;
                try
                {
                    this.listener.OnSnapshotEnd(itemPos, name);
                }
                catch (Exception)
                {
                }
            }
            else if (values.Overflow > 0)
            {
                if (!this.baseInfo.hasUnfilteredData())
                {
                    throw new PushServerException(7);
                }
                actionsLogger.Warn("Got notification of updates lost for item " + info);
                try
                {
                    this.listener.OnRawUpdatesLost(itemPos, name, values.Overflow);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                if ((this.extInfo != null) && (values.Size != this.extInfo.fields.Length))
                {
                    throw new PushServerException(3);
                }
                string[] array = values.Array;
                if (actionsLogger.IsDebugEnabled)
                {
                    actionsLogger.Debug(string.Concat(new object[] { "Got event for item ", info, " with values ", CollectionsSupport.ToString(array) }));
                }
                bool     snapshotPending = info.snapshotPending;
                string[] prevState       = info.Update(array);
                if (prevState != null)
                {
                    UpdateInfo update = new UpdateInfo(info, prevState, array, snapshotPending);
                    if (actionsLogger.IsDebugEnabled)
                    {
                        actionsLogger.Debug(string.Concat(new object[] { "Notifying event for item ", info, " with values ", update }));
                    }
                    try
                    {
                        this.listener.OnUpdate(itemPos, name, update);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        internal static void ProcessUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values, int itemIndex, ExtendedTableInfo table, IExtendedTableListener listener)
        {
            string item = table.items[itemIndex];

            if (values.EOS)
            {
                try
                {
                    listener.OnSnapshotEnd(item);
                }
                catch (Exception)
                {
                }
            }
            else if (values.Overflow > 0)
            {
                if (!table.hasUnfilteredData())
                {
                    throw new PushServerException(7);
                }
                actionsLogger.Warn("Got notification of updates lost for item " + item);
                try
                {
                    listener.OnRawUpdatesLost(item, values.Overflow);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                if (values.Size != table.fields.Length)
                {
                    throw new PushServerException(3);
                }
                IDictionary map = values.GetMap(table.fields);
                if (actionsLogger.IsDebugEnabled)
                {
                    actionsLogger.Debug("Got event for item " + item + " with values " + CollectionsSupport.ToString(map));
                }
                try
                {
                    listener.OnUpdate(item, map);
                }
                catch (Exception)
                {
                }
            }
        }
 public override string ToString()
 {
     return("event for item n\x00b0" + this.itemCode + " in window n\x00b0" + this.winCode + " with values " + CollectionsSupport.ToString(this.values));
 }
Пример #10
0
        internal virtual StreamReader GetAnswer(string controlUrl, Hashtable parameters, BatchMonitor batch)
        {
            BatchingHttpProvider batchToClose = null;

            BatchingHttpProvider.BufferedReaderMonitor monitor = null;
            bool flag = false;

            lock (batch)
            {
                lock (this)
                {
                    if (!batch.Filled)
                    {
                        batch.UseOne();
                        if (this.batchingProvider != null)
                        {
                            protLogger.Info("Batching control request");
                            if (protLogger.IsDebugEnabled)
                            {
                                protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters));
                            }
                            monitor = this.batchingProvider.AddCall(parameters);
                            if (monitor != null)
                            {
                                if (batch.Filled)
                                {
                                    batchToClose          = this.batchingProvider;
                                    this.batchingProvider = null;
                                }
                            }
                            else if (this.batchingProvider.Empty)
                            {
                                protLogger.Info("Batching failed; trying without batch");
                                if (batch.Filled)
                                {
                                    this.batchingProvider = null;
                                }
                            }
                            else
                            {
                                protLogger.Info("Batching failed; trying a new batch");
                                batchToClose = this.batchingProvider;
                                batch.Expand(1);
                                this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit);
                                flag = true;
                            }
                        }
                    }
                    else if (this.batchingProvider != null)
                    {
                        this.batchingProvider.Abort(new SubscrException("wrong requests batch"));
                        this.batchingProvider = null;
                    }
                }
            }
            if (batchToClose != null)
            {
                DoAsyncPost(batchToClose);
            }
            if (monitor != null)
            {
                return(monitor.GetReader());
            }
            if (flag)
            {
                return(this.GetAnswer(controlUrl, parameters, batch));
            }
            return(this.GetNotBatchedAnswer(controlUrl, parameters));
        }
        public virtual void DoUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
        {
            int itemCode = values.ItemCode;

            if (values.EOS)
            {
                try
                {
                    this.listener.OnSnapshotEnd(itemCode);
                }
                catch (Exception)
                {
                }
            }
            else if (values.Overflow > 0)
            {
                if (!this.table.hasUnfilteredData())
                {
                    throw new PushServerException(7);
                }
                try
                {
                    this.listener.OnRawUpdatesLost(itemCode, values.Overflow);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                string[] array = values.Array;
                if (actionsLogger.IsDebugEnabled)
                {
                    actionsLogger.Debug(string.Concat(new object[] { "Got event for item n\x00b0", itemCode, " in group ", this.table.group, " with values ", CollectionsSupport.ToString(array) }));
                }
                try
                {
                    this.listener.OnUpdate(itemCode, array);
                }
                catch (Exception)
                {
                }
            }
        }