private void DoControlRequest(PushServerProxy.PushServerProxyInfo pushInfo, Hashtable parameters, BatchMonitor batch)
        {
            string       controlUrl = pushInfo.controlAddress + "/lightstreamer/control.txt";
            StreamReader answer     = this.batchManager.GetAnswer(controlUrl, parameters, batch);

            try
            {
                this.CheckAnswer(answer);
            }
            finally
            {
                try
                {
                    if (!(answer is BatchingHttpProvider.MyReader))
                    {
                        streamLogger.Debug("Closing connection");
                    }
                    answer.Close();
                }
                catch (IOException exception)
                {
                    streamLogger.Debug("Error closing connection", exception);
                }
            }
        }
        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);
                }
            }
        }
        internal virtual void CallSendMessageRequest(PushServerProxy.PushServerProxyInfo pushInfo, string message)
        {
            Hashtable parameters = new Hashtable();

            parameters["LS_session"] = pushInfo.sessionId;
            parameters["LS_message"] = message;
            string       controlUrl       = pushInfo.controlAddress + "/lightstreamer/send_message.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);
                }
            }
        }
        internal virtual void CallDelete(string userId, PushServerProxy.PushServerProxyInfo pushInfo, string[] winCodes, BatchMonitor batch)
        {
            Hashtable parameters = new Hashtable();

            parameters["LS_session"] = pushInfo.sessionId;
            parameters["LS_op"]      = "delete";
            for (int i = 0; i < winCodes.Length; i++)
            {
                parameters["LS_window" + (i + 1)] = winCodes[i];
            }
            this.DoControlRequest(pushInfo, parameters, batch);
        }
        internal virtual void CallTableRequest(PushServerProxy.PushServerProxyInfo pushInfo, string winCode, ITableManager table, BatchMonitor batch)
        {
            Hashtable parameters = new Hashtable();

            parameters["LS_session"]    = pushInfo.sessionId;
            parameters["LS_op"]         = "add";
            parameters["LS_window"]     = winCode;
            parameters["LS_id" + 1]     = table.Group;
            parameters["LS_mode" + 1]   = table.Mode;
            parameters["LS_schema" + 1] = table.Schema;
            if (table.DataAdapter != null)
            {
                parameters["LS_data_adapter" + 1] = table.DataAdapter;
            }
            if (table.Selector != null)
            {
                parameters["LS_selector" + 1] = table.Selector;
            }
            if (table.Snapshot)
            {
                if (table.DistinctSnapshotLength != -1)
                {
                    parameters["LS_Snapshot" + 1] = table.DistinctSnapshotLength.ToString();
                }
                else
                {
                    parameters["LS_Snapshot" + 1] = "true";
                }
            }
            if (table.Start != -1)
            {
                parameters["LS_start" + 1] = table.Start.ToString();
            }
            if (table.End != -1)
            {
                parameters["LS_end" + 1] = table.End.ToString();
            }
            if (table.Unfiltered)
            {
                parameters["LS_requested_max_frequency" + 1] = "unfiltered";
            }
            else if (!(table.MaxFrequency == -1.0))
            {
                parameters["LS_requested_max_frequency" + 1] = table.MaxFrequency.ToString();
            }
            if (table.MaxBufferSize != -1)
            {
                parameters["LS_requested_buffer_size" + 1] = table.MaxBufferSize.ToString();
            }
            this.DoControlRequest(pushInfo, parameters, batch);
        }
        internal virtual void CallItemsRequest(PushServerProxy.PushServerProxyInfo pushInfo, string[] winCodes, VirtualTableManager table, BatchMonitor batch)
        {
            Hashtable parameters = new Hashtable();

            parameters["LS_session"] = pushInfo.sessionId;
            parameters["LS_op"]      = "add";
            parameters["LS_mode"]    = table.Mode;
            parameters["LS_schema"]  = table.Schema;
            if (table.DataAdapter != null)
            {
                parameters["LS_data_adapter"] = table.DataAdapter;
            }
            for (int i = 0; i < table.NumItems; i++)
            {
                parameters["LS_window" + (i + 1)] = winCodes[i];
                parameters["LS_id" + (i + 1)]     = table.GetItemName(i);
                if (table.Selector != null)
                {
                    parameters["LS_selector" + (i + 1)] = table.Selector;
                }
                if (table.Snapshot)
                {
                    if (table.DistinctSnapshotLength != -1)
                    {
                        parameters["LS_Snapshot" + (i + 1)] = table.DistinctSnapshotLength.ToString();
                    }
                    else
                    {
                        parameters["LS_Snapshot" + (i + 1)] = "true";
                    }
                }
                if (table.Unfiltered)
                {
                    parameters["LS_requested_max_frequency" + (i + 1)] = "unfiltered";
                }
                else if (!(table.MaxFrequency == -1.0))
                {
                    parameters["LS_requested_max_frequency" + (i + 1)] = table.MaxFrequency.ToString();
                }
                if (table.MaxBufferSize != -1)
                {
                    parameters["LS_requested_buffer_size" + (i + 1)] = table.MaxBufferSize.ToString();
                }
            }
            this.DoControlRequest(pushInfo, parameters, batch);
        }
        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));
        }
예제 #8
0
 internal virtual PushServerProxy.PushServerProxyInfo ReadSessionId(StreamReader pushStream)
 {
     string sessionId = null;
     string host = null;
     string uriString = null;
     string pushServerUrl = null;
     long keepaliveMillis = 0L;
     protLogger.Info("Reading stream connection info");
     while (true)
     {
         string str5 = pushStream.ReadLine();
         streamLogger.Debug("Read info line: " + str5);
         if (str5 == null)
         {
             throw new PushServerException(4);
         }
         if (str5.Trim().Equals(""))
         {
             if (sessionId == null)
             {
                 throw new PushServerException(7);
             }
             if (this.info.pushServerControlUrl != null)
             {
                 uriString = this.info.pushServerControlUrl;
             }
             else
             {
                 uriString = this.info.pushServerUrl;
             }
             pushServerUrl = this.info.pushServerUrl;
             if (host != null)
             {
                 Uri uri = new Uri(uriString);
                 UriBuilder builder = new UriBuilder(uri.Scheme, host, uri.Port, uri.AbsolutePath);
                 uriString = builder.Uri.ToString();
                 if (uriString.EndsWith("/"))
                 {
                     uriString = uriString.Substring(0, uriString.Length - 1);
                 }
                 Uri uri3 = new Uri(pushServerUrl);
                 UriBuilder builder2 = new UriBuilder(uri3.Scheme, host, uri3.Port, uri3.AbsolutePath);
                 pushServerUrl = builder2.Uri.ToString();
                 if (pushServerUrl.EndsWith("/"))
                 {
                     pushServerUrl = pushServerUrl.Substring(0, pushServerUrl.Length - 1);
                 }
             }
             PushServerProxy.PushServerProxyInfo info = new PushServerProxy.PushServerProxyInfo(sessionId, uriString, pushServerUrl, keepaliveMillis);
             if (protLogger.IsDebugEnabled)
             {
                 protLogger.Debug("Using info: " + info);
             }
             return info;
         }
         if (str5.StartsWith("SessionId:"))
         {
             sessionId = str5.Substring("SessionId:".Length);
         }
         else if (str5.StartsWith("ControlAddress:"))
         {
             host = str5.Substring("ControlAddress:".Length);
         }
         else if (str5.StartsWith("KeepaliveMillis:"))
         {
             string s = str5.Substring("KeepaliveMillis:".Length);
             try
             {
                 keepaliveMillis = long.Parse(s);
             }
             catch (FormatException)
             {
                 throw new PushServerException(7);
             }
         }
         else if (!str5.StartsWith("MaxBandwidth:"))
         {
             if (str5.StartsWith("RequestLimit:"))
             {
                 long num2;
                 string str7 = str5.Substring("RequestLimit:".Length);
                 try
                 {
                     num2 = long.Parse(str7);
                 }
                 catch (FormatException)
                 {
                     throw new PushServerException(7);
                 }
                 streamLogger.Debug("Using " + num2 + " as the request maximum length");
                 this.batchManager.Limit = num2;
             }
             else
             {
                 protLogger.Info("Discarded unknown property: " + str5);
             }
         }
     }
 }
예제 #9
0
 internal virtual PushServerProxy.PushServerProxyInfo ReadSessionId(StreamReader pushStream)
 {
     string sessionId = null;
     string controlHost = null;
     string controlAddress = null;
     string rebindAddress = null;
     long keepaliveMillis = 0L;
     protLogger.Info("Reading stream connection info");
     while (true)
     {
         string str = pushStream.ReadLine();
         streamLogger.Debug("Read info line: " + str);
         if (str == null)
         {
             throw new PushServerException(4);
         }
         if (str.Trim().Equals(""))
         {
             if (sessionId == null)
             {
                 throw new PushServerException(7);
             }
             if (this.info.PushServerControlUrl != null)
             {
                 controlAddress = this.info.PushServerControlUrl;
             }
             else
             {
                 controlAddress = this.info.PushServerUrl;
             }
             rebindAddress = this.info.PushServerUrl;
             if (controlHost != null)
             {
                 Uri ca = new Uri(controlAddress);
                 UriBuilder temp_uri = new UriBuilder(ca.Scheme, controlHost, ca.Port, ca.AbsolutePath);
                 controlAddress = temp_uri.Uri.ToString();
                 if (controlAddress.EndsWith("/"))
                 {
                     controlAddress = controlAddress.Substring(0, controlAddress.Length - 1);
                 }
                 Uri ra = new Uri(rebindAddress);
                 UriBuilder temp_uri2 = new UriBuilder(ra.Scheme, controlHost, ra.Port, ra.AbsolutePath);
                 rebindAddress = temp_uri2.Uri.ToString();
                 if (rebindAddress.EndsWith("/"))
                 {
                     rebindAddress = rebindAddress.Substring(0, rebindAddress.Length - 1);
                 }
             }
             PushServerProxy.PushServerProxyInfo pspInfo = new PushServerProxy.PushServerProxyInfo(sessionId, controlAddress, rebindAddress, keepaliveMillis);
             if (protLogger.IsDebugEnabled)
             {
                 protLogger.Debug("Using info: " + pspInfo);
             }
             return pspInfo;
         }
         if (str.StartsWith("SessionId:"))
         {
             sessionId = str.Substring("SessionId:".Length);
         }
         else if (str.StartsWith("ControlAddress:"))
         {
             controlHost = str.Substring("ControlAddress:".Length);
         }
         else if (str.StartsWith("KeepaliveMillis:"))
         {
             string keepaliveMillisStr = str.Substring("KeepaliveMillis:".Length);
             try
             {
                 keepaliveMillis = long.Parse(keepaliveMillisStr);
             }
             catch (FormatException)
             {
                 throw new PushServerException(7);
             }
         }
         else if (!str.StartsWith("MaxBandwidth:"))
         {
             if (str.StartsWith("RequestLimit:"))
             {
                 long requestLimit;
                 string requestLimitStr = str.Substring("RequestLimit:".Length);
                 try
                 {
                     requestLimit = long.Parse(requestLimitStr);
                 }
                 catch (FormatException)
                 {
                     throw new PushServerException(7);
                 }
                 streamLogger.Debug("Using " + requestLimit + " as the request maximum length");
                 this.batchManager.Limit = requestLimit;
                 this.mexBatchManager.Limit = requestLimit;
             }
             else
             {
                 protLogger.Info("Discarded unknown property: " + str);
             }
         }
     }
 }
예제 #10
0
 public AnonymousClassThread2(PushServerProxy.PushServerProxyInfo closingServerInfo, PushServerProxy enclosingInstance)
 {
     this.closingServerInfo = closingServerInfo;
     this.enclosingInstance = enclosingInstance;
 }
        internal virtual void StartControlBatch(PushServerProxy.PushServerProxyInfo pushInfo)
        {
            string controlUrl = pushInfo.controlAddress + "/lightstreamer/control.txt";

            this.batchManager.StartBatch(controlUrl);
        }
        internal virtual PushServerProxy.PushServerProxyInfo ReadSessionId(StreamReader pushStream)
        {
            string sessionId       = null;
            string host            = null;
            string uriString       = null;
            string pushServerUrl   = null;
            long   keepaliveMillis = 0L;

            protLogger.Info("Reading stream connection info");
            while (true)
            {
                string str5 = pushStream.ReadLine();
                streamLogger.Debug("Read info line: " + str5);
                if (str5 == null)
                {
                    throw new PushServerException(4);
                }
                if (str5.Trim().Equals(""))
                {
                    if (sessionId == null)
                    {
                        throw new PushServerException(7);
                    }
                    if (this.info.pushServerControlUrl != null)
                    {
                        uriString = this.info.pushServerControlUrl;
                    }
                    else
                    {
                        uriString = this.info.pushServerUrl;
                    }
                    pushServerUrl = this.info.pushServerUrl;
                    if (host != null)
                    {
                        Uri        uri     = new Uri(uriString);
                        UriBuilder builder = new UriBuilder(uri.Scheme, host, uri.Port, uri.PathAndQuery);
                        uriString = builder.Uri.ToString();
                        if (uriString.EndsWith("/"))
                        {
                            uriString = uriString.Substring(0, uriString.Length - 1);
                        }
                        Uri        uri3     = new Uri(pushServerUrl);
                        UriBuilder builder2 = new UriBuilder(uri3.Scheme, host, uri3.Port, uri3.PathAndQuery);
                        pushServerUrl = builder2.Uri.ToString();
                        if (pushServerUrl.EndsWith("/"))
                        {
                            pushServerUrl = pushServerUrl.Substring(0, pushServerUrl.Length - 1);
                        }
                    }
                    PushServerProxy.PushServerProxyInfo info = new PushServerProxy.PushServerProxyInfo(sessionId, uriString, pushServerUrl, keepaliveMillis);
                    if (protLogger.IsDebugEnabled)
                    {
                        protLogger.Debug("Using info: " + info);
                    }
                    return(info);
                }
                if (str5.StartsWith("SessionId:"))
                {
                    sessionId = str5.Substring("SessionId:".Length);
                }
                else if (str5.StartsWith("ControlAddress:"))
                {
                    host = str5.Substring("ControlAddress:".Length);
                }
                else if (str5.StartsWith("KeepaliveMillis:"))
                {
                    string s = str5.Substring("KeepaliveMillis:".Length);
                    try
                    {
                        keepaliveMillis = long.Parse(s);
                    }
                    catch (FormatException)
                    {
                        throw new PushServerException(7);
                    }
                }
                else if ((!str5.StartsWith("TopMaxFrequency:") && !str5.StartsWith("SlowingFactor:")) && !str5.StartsWith("MaxBandwidth:"))
                {
                    if (str5.StartsWith("RequestLimit:"))
                    {
                        long   num2;
                        string str7 = str5.Substring("RequestLimit:".Length);
                        try
                        {
                            num2 = long.Parse(str7);
                        }
                        catch (FormatException)
                        {
                            throw new PushServerException(7);
                        }
                        streamLogger.Debug("Using " + num2 + " as the request maximum length");
                        this.batchManager.Limit = num2;
                    }
                    else
                    {
                        protLogger.Info("Discarded unknown property: " + str5);
                    }
                }
            }
        }