Ejemplo n.º 1
0
 public virtual void DoUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     int itemCode = values.ItemCode;
     if ((itemCode <= 0) || (itemCode > this.table.items.Length))
     {
         throw new PushServerException(2);
     }
     ProcessUpdate(values, itemCode - 1, this.table, this.listener);
 }
 private static void AddConstraints(Hashtable parameters, Lightstreamer.DotNet.Client.ConnectionConstraints constraints)
 {
     if (!(constraints.maxBandwidth == -1.0))
     {
         parameters["LS_requested_max_bandwidth"] = constraints.maxBandwidth.ToString();
     }
     if (!(constraints.topMaxFrequency == -1.0))
     {
         parameters["LS_top_max_frequency"] = constraints.topMaxFrequency.ToString();
     }
     else if (!(constraints.slowingFactor == -1.0))
     {
         parameters["LS_slowing_factor"] = constraints.slowingFactor.ToString();
     }
 }
Ejemplo n.º 3
0
 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)
         {
         }
     }
 }
Ejemplo n.º 4
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)
         {
         }
     }
 }
Ejemplo n.º 5
0
 public virtual void ChangeConstraints(Lightstreamer.DotNet.Client.ConnectionConstraints constraints)
 {
     ServerManager currConnManager;
     try
     {
         currConnManager = this.ConnManager;
     }
     catch (SubscrException)
     {
         return;
     }
     try
     {
         currConnManager.ChangeConstraints(constraints);
     }
     catch (PhaseException)
     {
     }
 }
Ejemplo n.º 6
0
 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)
         {
         }
     }
 }
Ejemplo n.º 7
0
 public virtual void DoUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     if (values.ItemCode != 1)
     {
         throw new PushServerException(2);
     }
     this.enclosingInstance.managerWithListener.ProcessUpdate(values, this.itemIndex + 1, this.itemIndex);
 }
Ejemplo n.º 8
0
 internal virtual void UnsubscrTables(Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys, bool batchable)
 {
     if (subscrKeys.Length == 0)
     {
         if (batchable)
         {
             this.UnbatchRequest();
         }
     }
     else
     {
         this.localPushServerProxy.DelSubscrs(subscrKeys, batchable ? this.batchMonitor : null);
     }
 }
Ejemplo n.º 9
0
 private void MessageUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     if (values.ErrorCode == 0x27)
     {
         this.ExpandMultipleMessageUpdate(values);
     }
     else
     {
         lock (this.sequencesHandler)
         {
             SequenceHandler seq = this.sequencesHandler.GetSequence(values.MessageSequence);
             MessageManager message = seq.GetMessage(values.MessageProg);
             if (message == null)
             {
                 this.serverListener.OnDataError(new PushServerException(13));
             }
             else
             {
                 this.serverListener.OnMessageOutcome(message, seq, values, null);
             }
         }
     }
 }
Ejemplo n.º 10
0
 private void ExpandMultipleMessageUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     int losts = 0;
     bool ok = false;
     try
     {
         losts = Convert.ToInt32(values.ErrorMessage);
         ok = true;
     }
     catch (FormatException)
     {
     }
     catch (OverflowException)
     {
     }
     finally
     {
         if (!ok)
         {
             this.serverListener.OnDataError(new PushServerException(7));
         }
     }
     if (ok && (losts > 0))
     {
         for (int next = (values.MessageProg - losts) + 1; next <= values.MessageProg; next++)
         {
             this.MessageUpdate(new Lightstreamer.DotNet.Client.ServerUpdateEvent(values.MessageSequence, next, 0x26, "Message discarded"));
         }
     }
 }
Ejemplo n.º 11
0
 internal virtual void ChangeConstraints(Lightstreamer.DotNet.Client.ConnectionConstraints constraints)
 {
     this.localPushServerProxy.RequestNewConstraints(constraints);
 }
Ejemplo n.º 12
0
 public virtual void ForceUnsubscribeTable(Lightstreamer.DotNet.Client.SubscribedTableKey tableKey)
 {
     ServerManager currConnManager = this.ConnManager;
     if (tableKey.KeyValue != -1)
     {
         Lightstreamer.DotNet.Client.SubscribedTableKey[] tableKeys = new Lightstreamer.DotNet.Client.SubscribedTableKey[] { tableKey };
         try
         {
             currConnManager.UnsubscrTables(tableKeys, false);
         }
         catch (PhaseException)
         {
             throw new SubscrException("Connection closed");
         }
     }
 }
Ejemplo n.º 13
0
 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)
         {
             IUpdateInfo update = new UpdateInfoImpl(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)
             {
             }
         }
     }
 }
Ejemplo n.º 14
0
 public virtual void DoUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     int itemCode = values.ItemCode;
     int itemIndex = itemCode - 1;
     this.ProcessUpdate(values, itemCode, itemIndex);
 }
Ejemplo n.º 15
0
 public virtual void UnsubscribeTables(Lightstreamer.DotNet.Client.SubscribedTableKey[] tableKeys)
 {
     int num2;
     ServerManager connManager = this.ConnManager;
     ITableManager[] managerArray = connManager.DetachTables(tableKeys);
     int num = 0;
     for (num2 = 0; num2 < managerArray.Length; num2++)
     {
         if (managerArray[num2] != null)
         {
             managerArray[num2].NotifyUnsub();
             num++;
         }
     }
     if (num == 0)
     {
     }
     Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys = new Lightstreamer.DotNet.Client.SubscribedTableKey[num];
     int index = 0;
     for (num2 = 0; num2 < managerArray.Length; num2++)
     {
         if (managerArray[num2] != null)
         {
             subscrKeys[index] = tableKeys[num2];
             index++;
         }
     }
     try
     {
         connManager.UnsubscrTables(subscrKeys, true);
     }
     catch (PhaseException)
     {
         throw new SubscrException("Connection closed");
     }
 }
Ejemplo n.º 16
0
 public virtual void DoUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     throw new PushServerException(12);
 }
 internal virtual void CallConstrainRequest(PushServerProxy.PushServerProxyInfo pushInfo, Lightstreamer.DotNet.Client.ConnectionConstraints newConstraints)
 {
     Hashtable parameters = new Hashtable();
     parameters["LS_session"] = pushInfo.sessionId;
     parameters["LS_op"] = "constrain";
     this.info.constraints = (Lightstreamer.DotNet.Client.ConnectionConstraints) newConstraints.Clone();
     AddConstraints(parameters, this.info.constraints);
     string controlUrl = pushInfo.controlAddress + "/lightstreamer/control.txt";
     StreamReader notBatchedAnswer = this.batchManager.GetNotBatchedAnswer(controlUrl, parameters);
     try
     {
         this.CheckAnswer(notBatchedAnswer);
     }
     finally
     {
         try
         {
             streamLogger.Debug("Closing connection");
             notBatchedAnswer.Close();
         }
         catch (IOException exception)
         {
             streamLogger.Debug("Error closing connection", exception);
         }
     }
 }
Ejemplo n.º 18
0
 internal virtual Stream CallResync(PushServerProxy.PushServerProxyInfo pushInfo, Lightstreamer.DotNet.Client.ConnectionConstraints newConstraints)
 {
     IDictionary parameters = new Dictionary<string, string>();
     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", this.cookies);
     protLogger.Info("Opening stream connection to rebind current session");
     if (protLogger.IsDebugEnabled)
     {
         protLogger.Debug("Rebinding params: " + CollectionsSupport.ToString(parameters));
     }
     parameters["LS_silverlightWP_version"] = Constants.localVersion;
     bool useGet = !this.info.Polling && this.info.useGetForStreaming;
     return provider.DoHTTP(parameters, !useGet);
 }
Ejemplo n.º 19
0
 public virtual void UnsubscribeTable(Lightstreamer.DotNet.Client.SubscribedTableKey tableKey)
 {
     ServerManager currConnManager = this.ConnManager;
     if (tableKey.KeyValue != -1)
     {
         Lightstreamer.DotNet.Client.SubscribedTableKey[] tableKeys = new Lightstreamer.DotNet.Client.SubscribedTableKey[] { tableKey };
         ITableManager[] infos = currConnManager.DetachTables(tableKeys);
         if (infos[0] == null)
         {
             try
             {
                 currConnManager.UnsubscrTables(new Lightstreamer.DotNet.Client.SubscribedTableKey[0], true);
             }
             catch (PhaseException)
             {
             }
             throw new SubscrException("Table not found");
         }
         infos[0].NotifyUnsub();
         try
         {
             currConnManager.UnsubscrTables(tableKeys, true);
         }
         catch (PhaseException)
         {
             throw new SubscrException("Connection closed");
         }
     }
 }
Ejemplo n.º 20
0
 private static void AddConstraints(IDictionary parameters, Lightstreamer.DotNet.Client.ConnectionConstraints constraints)
 {
     if (!(constraints.MaxBandwidth == -1.0))
     {
         parameters["LS_requested_max_bandwidth"] = constraints.MaxBandwidth.ToString();
     }
 }
Ejemplo n.º 21
0
 public virtual void UnsubscribeTables(Lightstreamer.DotNet.Client.SubscribedTableKey[] tableKeys)
 {
     int i;
     ServerManager currConnManager = this.ConnManager;
     ITableManager[] infos = currConnManager.DetachTables(tableKeys);
     int found = 0;
     for (i = 0; i < infos.Length; i++)
     {
         if (infos[i] != null)
         {
             infos[i].NotifyUnsub();
             found++;
         }
     }
     if (found == 0)
     {
     }
     Lightstreamer.DotNet.Client.SubscribedTableKey[] foundTableKeys = new Lightstreamer.DotNet.Client.SubscribedTableKey[found];
     int curr = 0;
     for (i = 0; i < infos.Length; i++)
     {
         if (infos[i] != null)
         {
             foundTableKeys[curr] = tableKeys[i];
             curr++;
         }
     }
     try
     {
         currConnManager.UnsubscrTables(foundTableKeys, true);
     }
     catch (PhaseException)
     {
         throw new SubscrException("Connection closed");
     }
 }
Ejemplo n.º 22
0
 internal virtual void RequestItemsSubscr(VirtualTableManager table, Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys, BatchMonitor batch)
 {
     string[] winCodes = new string[subscrKeys.Length];
     for (int i = 0; i < subscrKeys.Length; i++)
     {
         winCodes[i] = subscrKeys[i].KeyValue.ToString();
     }
     this.Check();
     try
     {
         this.serverTranslator.CallItemsRequest(this.serverInfo, winCodes, table, batch);
     }
     catch (IOException exception)
     {
         throw new PushConnException(exception);
     }
     catch (WebException exception2)
     {
         throw new PushConnException(exception2);
     }
     this.Check();
 }
Ejemplo n.º 23
0
 internal virtual ITableManager[] DetachTables(Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys)
 {
     int i;
     ITableManager[] infos = new ITableManager[subscrKeys.Length];
     lock (this.tables.SyncRoot)
     {
         i = 0;
         while (i < subscrKeys.Length)
         {
             if (subscrKeys[i].KeyValue != -1)
             {
                 object tempObject = this.tables[subscrKeys[i].KeyValue];
                 this.tables.Remove(subscrKeys[i].KeyValue);
                 infos[i] = (ITableManager) tempObject;
             }
             else
             {
                 infos[i] = null;
             }
             i++;
         }
     }
     if (actionsLogger.IsInfoEnabled)
     {
         for (i = 0; i < subscrKeys.Length; i++)
         {
             actionsLogger.Info(string.Concat(new object[] { "Removed ", infos[i], " from session ", this.localPushServerProxy.SessionId }));
         }
     }
     return infos;
 }
Ejemplo n.º 24
0
 internal virtual void RequestNewConstraints(Lightstreamer.DotNet.Client.ConnectionConstraints constraints)
 {
     this.Check();
     try
     {
         this.serverTranslator.CallConstrainRequest(this.serverInfo, constraints);
     }
     catch (PushUserException exception)
     {
         protLogger.Debug("Refused constraints request", exception);
         throw new PushServerException(7);
     }
     catch (IOException exception2)
     {
         throw new PushConnException(exception2);
     }
     catch (WebException exception3)
     {
         throw new PushConnException(exception3);
     }
     this.Check();
 }
Ejemplo n.º 25
0
 private ITableManager GetUpdatedTable(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     lock (this.tables.SyncRoot)
     {
         return (ITableManager) this.tables[values.TableCode];
     }
 }
Ejemplo n.º 26
0
 internal virtual void RequestSubscr(ITableManager table, Lightstreamer.DotNet.Client.SubscribedTableKey subscrKey, BatchMonitor batch)
 {
     string winCode = subscrKey.KeyValue.ToString();
     this.Check();
     try
     {
         this.serverTranslator.CallTableRequest(this.serverInfo, winCode, table, batch);
     }
     catch (IOException exception)
     {
         throw new PushConnException(exception);
     }
     catch (WebException exception2)
     {
         throw new PushConnException(exception2);
     }
     this.Check();
 }
Ejemplo n.º 27
0
 private void TableUpdate(Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     ITableManager table = this.GetUpdatedTable(values);
     if (table == null)
     {
         if (!this.localPushServerProxy.IsTableCodeConsumed(values.TableCode))
         {
             this.serverListener.OnDataError(new PushServerException(1));
         }
     }
     else
     {
         this.serverListener.OnUpdate(table, values);
     }
 }
Ejemplo n.º 28
0
 internal virtual void DelSubscrs(Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys, BatchMonitor batch)
 {
     string[] winCodes = new string[subscrKeys.Length];
     for (int i = 0; i < subscrKeys.Length; i++)
     {
         winCodes[i] = subscrKeys[i].KeyValue.ToString();
     }
     this.Check();
     try
     {
         this.serverTranslator.CallDelete(this.userId, this.serverInfo, winCodes, batch);
     }
     catch (PushUserException exception)
     {
         protLogger.Debug("Refused delete request", exception);
         throw new PushServerException(7);
     }
     catch (IOException exception2)
     {
         throw new PushConnException(exception2);
     }
     catch (WebException exception3)
     {
         throw new PushConnException(exception3);
     }
     this.Check();
 }
Ejemplo n.º 29
0
 public virtual bool OnUpdate(ITableManager table, Lightstreamer.DotNet.Client.ServerUpdateEvent values)
 {
     if (this.owner.GetActiveListener(this.currPhase) != null)
     {
         try
         {
             table.DoUpdate(values);
         }
         catch (PushServerException exception)
         {
             actionsLogger.Debug("Error in received values", exception);
             this.OnDataError(exception);
         }
         return true;
     }
     return false;
 }
 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);
 }