Exemple #1
0
 private void CallbackOPENDATA(object state, bool timedOut)
 {
     if (_RESPONSE.Handle != null)
     {
         _RESPONSE.Handle.Unregister(null); _RESPONSE.Handle = null;
     }                                                                                            // Stop future execution of the callback method
     if (timedOut && OnError.GetInvocationList().Length > 0)
     {
         OnError(this, new Exception("OPENDATA: Timed Out."));
     }
     else
     {
         if (_RESPONSE.Text.StartsWith("GOOD") && _RESPONSE.Text.EndsWith("GOOD"))
         {
             // Try to connect to the data port
             int dataport = Convert.ToInt32(_RESPONSE.Text.Substring(4, 8), 16);
             var endpoint = SVSEUtility.CreateIPEndpoint(_socketComm.RemoteIPAddress.ToString(), dataport);
             _socketData.Connect(endpoint);
         }
         else if (_RESPONSE.Text.StartsWith("FAIL"))
         {
             if (OnError.GetInvocationList().Length > 0)
             {
                 OnError(this, new Exception("OPENDATA: " + _RESPONSE.Text));
             }
         }
     }
 }
Exemple #2
0
        public void Startup(string host, int port, string userId, string password)
        {
            _userId   = userId.Trim();
            _password = password.Trim();

            try
            {
                var endpoint = SVSEUtility.CreateIPEndpoint(host.Trim(), port, out _ipAddress);
                _socketComm.Connect(endpoint);
            }
            catch (Exception exc)
            {
                if (OnError.GetInvocationList().Length > 0)
                {
                    OnError(this, exc);
                }
            }
        }