コード例 #1
0
        /// <summary>
        /// 在指定时间内尝试连接指定主机上的指定端口。 (默认端口:80,默认链接超时:5000毫秒)
        /// </summary>
        /// <param name= "hostname ">要连接到的远程主机的 DNS 名。</param>
        /// <param name= "port ">要连接到的远程主机的端口号。 </param>
        /// <param name= "millisecondsTimeout ">要等待的毫秒数,或 -1 表示无限期等待。</param>
        /// <returns>已连接的一个 TcpClient 实例。</returns>
        public static TcpClient Connect(string hostname, int?port, int?millisecondsTimeout)
        {
            ConnectorState cs = new ConnectorState();

            cs.Hostname = hostname;
            cs.Port     = port ?? 80;

            ThreadPool.QueueUserWorkItem(new WaitCallback(ConnectThreaded), cs);
            if (cs.Completed.WaitOne(millisecondsTimeout ?? 5000, false))
            {
                if (cs.TcpClient != null)
                {
                    return(cs.TcpClient);
                }
                return(null);

                //throw cs.Exception;
            }
            else
            {
                cs.Abort();
                return(null);

                //throw new SocketException(11001); // cannot connect
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets the state of the connector space object
        /// </summary>
        /// <param name="connectorState">The state to set the connector to</param>
        public void SetConnectorState(ConnectorState connectorState)
        {
            string result = ws.SetConnectorState(this.MAID.ToMmsGuid(), this.ID.ToMmsGuid(), (CONNECTORSTATE)connectorState);

            SyncServer.ThrowExceptionOnReturnError(result);
            this.Refresh();
        }
コード例 #3
0
ファイル: TcpClientConnector.cs プロジェクト: tliangA/KillJD
        private static void ConnectThreaded(object state)
        {
            ConnectorState cs = (ConnectorState)state;

            cs.Thread = Thread.CurrentThread;
            try
            {
                TcpClient tc = new TcpClient(cs.Hostname, cs.Port);
                if (cs.Aborted)
                {
                    try { tc.GetStream().Close(); }
                    catch { }
                    try { tc.Close(); }
                    catch { }
                }
                else
                {
                    cs.TcpClient = tc;
                    cs.Completed.Set();
                }
            }
            catch (Exception e)
            {
                cs.Exception = e;
                cs.Completed.Set();
            }
        }
コード例 #4
0
ファイル: Connector.cs プロジェクト: 470838237/UnityDemo
        void OnStateChangedProc(int state, byte[] resultdata)
        {
            ConnectorResult result = convertConnectorResult(resultdata);
            ConnectorState  s      = (ConnectorState)state;

            ADebug.Log("OnStateChangedProc state: " + s + " " + result.ToString());
            if (s == ConnectorState.Reconnected && result.IsSuccess())
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            if (StateChangedEvent != null)
            {
                try
                {
                    StateChangedEvent(s, result);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
コード例 #5
0
        private void SetSimConnectControls(ConnectorState state, string statusMessage)
        {
            lblSimStatus.Text = statusMessage;
            switch (state)
            {
            case ConnectorState.Connected:
                lblSimStatus.ForeColor = Color.Green;
                buttonSimConnect.Text  = "Disconnect from SimConnect";
                break;

            case ConnectorState.Connecting:
                lblSimStatus.ForeColor = Color.Black;
                buttonSimConnect.Text  = "Disconnect from SimConnect";
                break;

            case ConnectorState.Disconnected:
                lblSimStatus.ForeColor = Color.Black;
                buttonSimConnect.Text  = "Connect to SimConnect";
                break;

            case ConnectorState.Retrying:
                lblSimStatus.ForeColor = Color.Red;
                buttonSimConnect.Text  = "Disconnect from SimConnect";
                lblSimStatus.Text     += "... Retrying";
                break;
            }

            lblSimStatus.Invalidate();
            buttonSimConnect.Invalidate();
        }
コード例 #6
0
ファイル: ManagementAgent.cs プロジェクト: Jvcamp/miis-client
        public CSObjectEnumerator GetDisconnectors(ConnectorState state)
        {
            string type;

            switch (state)
            {
            case ConnectorState.Normal:
                type = "normal";
                break;

            case ConnectorState.Explicit:
                type = "explicit";
                break;

            case ConnectorState.Filtered:
                type = "stay";
                break;

            default:
                throw new InvalidOperationException("Unknown connector type");
            }

            string searchText = $"<criteria><connector>false</connector><connector-state>{type}</connector-state></criteria>";

            return(this.ExportConnectorSpace(searchText));
        }
コード例 #7
0
 /// <inheritdoc/>
 public override void OnBeforeDebugAdjustablesUpdate()
 {
     _dbgOldConnectorState = connectorState;
     if (connectorState == ConnectorState.Deployed)
     {
         _dbgOldCableLength = currentCableLength;
         SaveConnectorModelPosAndRot();
         _dbgOldConnectorPosAndRot = persistedConnectorPosAndRot;
         SetConnectorState(ConnectorState.Locked);
     }
     base.OnBeforeDebugAdjustablesUpdate();
 }
コード例 #8
0
        /// <summary>
        /// Loads the settings.
        /// </summary>
        /// <returns></returns>
        private ConnectorState LoadState()
        {
            string settingFilePath = ConfigurationManager.GetInstance().GetStateFilePath();

            if (File.Exists(settingFilePath) == false)
            {
                return(new ConnectorState());
            }

            ConnectorState configuration = SerializationManager.ReadSettings <ConnectorState>(settingFilePath);

            return(configuration);
        }
コード例 #9
0
        public async ValueTask OpenAsync(string host, string database, string userName, string password,
                                         CancellationToken cancellationToken)
        {
            m_connectorState = ConnectorState.Connecting;
            var socketTask = ConnectAsync(host);
            var socket     = socketTask.IsCompletedSuccessfully
                ? socketTask.Result
                : await socketTask.ConfigureAwait(false);

            var sendBufferBytes    = m_arrayPool.Rent(512);
            var receiveBufferBytes = m_arrayPool.Rent(512);

            try
            {
                var sendBuffer    = new Memory <byte>(sendBufferBytes);
                var receiveBuffer = new Memory <byte>(sendBufferBytes);

                var sender = new SocketSender(socket);
                var sendStartupMessageTask =
                    SendStartupMessage(sender, sendBuffer, database, userName, cancellationToken);
                if (!sendStartupMessageTask.IsCompletedSuccessfully)
                {
                    await sendStartupMessageTask.ConfigureAwait(false);
                }

                var receiver = new SocketReceiver(socket);
                var processStartupMessageResponseTask = ProcessStartupMessageResponse(sender, sendBuffer, receiver, receiveBuffer,
                                                                                      userName, password, cancellationToken);
                if (!processStartupMessageResponseTask.IsCompletedSuccessfully)
                {
                    await processStartupMessageResponseTask.ConfigureAwait(false);
                }

                m_connectorState = ConnectorState.ReadyForQuery;

                m_connectionInfo          = new ConnectionInfo();
                m_connectionInfo.Host     = host;
                m_connectionInfo.Database = database;
                m_connectionInfo.UserName = userName;
                m_connectionInfo.Password = password;

                m_socket = socket;
            }
            finally
            {
                m_arrayPool.Return(sendBufferBytes);
                m_arrayPool.Return(receiveBufferBytes);
            }
        }
コード例 #10
0
 public void Disconnect()
 {
     if (State != ConnectorState.Disconnected)
     {
         State = ConnectorState.Disconnecting;
         try
         {
             Disconnecting();
             Disconnected(_connectParamsWhereConnect);
         }
         catch { }
         finally
         {
             State = ConnectorState.Disconnected;
         }
     }
 }
コード例 #11
0
    public void Unlock(bool justUnlocked, string sourceLevel)
    {
        this.sourceLevel = sourceLevel;

        if (justUnlocked)
        {
            state = ConnectorState.JustUnlocked;
        }
        else
        {
            state = ConnectorState.PreviouslyUnlocked;
            if (DestinationNode != null)
            {
                DestinationNode.Unlock(sourceLevel);
            }
        }
        animator.SetInteger("State", (int)state);
    }
コード例 #12
0
        //---------------------------------------------------------------------
        public void Connect(TConnectorConnectParams connectParams)
        {
            if (IsConnected)
            {
                throw new InvalidOperationException();
            }
            if (connectParams == null)
            {
                throw new ArgumentNullException(nameof(connectParams));
            }

            _connectParamsWhereConnect = connectParams;
            State = ConnectorState.Connecting;

            Connecting(connectParams);
            Connected(connectParams);

            State = ConnectorState.Connected;
        }
コード例 #13
0
ファイル: TcpClientConnector.cs プロジェクト: hanksoft/KillJD
 /// <summary> 
 /// 在指定时间内尝试连接指定主机上的指定端口。 (默认端口:80,默认链接超时:5000毫秒)
 /// </summary> 
 /// <param name= "hostname ">要连接到的远程主机的 DNS 名。</param> 
 /// <param name= "port ">要连接到的远程主机的端口号。 </param> 
 /// <param name= "millisecondsTimeout ">要等待的毫秒数,或 -1 表示无限期等待。</param> 
 /// <returns>已连接的一个 TcpClient 实例。</returns> 
 public static TcpClient Connect(string hostname, int? port, int? millisecondsTimeout)
 {
     ConnectorState cs = new ConnectorState();
     cs.Hostname = hostname;
     cs.Port = port ?? 80;
     ThreadPool.QueueUserWorkItem(new WaitCallback(ConnectThreaded), cs);
     if (cs.Completed.WaitOne(millisecondsTimeout ?? 5000, false))
     {
         if (cs.TcpClient != null) return cs.TcpClient;
         return null;
         //throw cs.Exception;
     }
     else
     {
         cs.Abort();
         return null;
         //throw new SocketException(11001); // cannot connect 
     }
 }
コード例 #14
0
        private void SetForeflightControls(ConnectorState state)
        {
            if (ConnectorState.Connected == state)
            {
                lblForeFlightStatus.Text        = "ForeFlight Sender started.";
                lblForeFlightStatus.ForeColor   = Color.Green;
                tbForeflightIP.Enabled          = false;
                cbForeflightConnectType.Enabled = false;
                buttonForeflight.Text           = "Stop Foreflight Sender";
            }
            else
            {
                buttonForeflight.Text           = "Start ForeFlight Sender";
                lblForeFlightStatus.Text        = "ForeFlight Sender stopped.";
                lblForeFlightStatus.ForeColor   = Color.Black;
                tbForeflightIP.Enabled          = true;
                cbForeflightConnectType.Enabled = true;
            }

            lblForeFlightStatus.Invalidate();
            tbForeflightIP.Invalidate();
            cbForeflightConnectType.Invalidate();
            buttonForeflight.Invalidate();
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: ItzWarty/AdventuresInShade
 public void Break()
 {
     connectorState = ConnectorState.Banned;
 }
コード例 #16
0
ファイル: ServerConnector.cs プロジェクト: prepare/deveeldb
 protected void ChangeState(ConnectorState newState)
 {
     AssertNotDisposed();
     CurrentState = newState;
 }
コード例 #17
0
ファイル: Connector.cs プロジェクト: hexu6788/HSQL
 public Connector(IDbConnection connection)
 {
     _state      = ConnectorState.可用;
     _connection = connection;
 }
コード例 #18
0
 /// <summary>
 /// Sets the connector state of a specified connector
 /// </summary>
 /// <param name="id">The ID of the connector space object</param>
 /// <param name="maid">The ID of the management agent containing the connector space object</param>
 /// <param name="connectorState">The state of the connector to set</param>
 public static void SetConnectorState(Guid id, Guid maid, ConnectorState connectorState)
 {
     CSObject.ws.SetConnectorState(maid.ToMmsGuid(), id.ToMmsGuid(), (CONNECTORSTATE)connectorState);
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: ItzWarty/AdventuresInShade
 public CellConnector(Cell first, Cell second, Line2D segment,  ConnectorState connectorState = ConnectorState.Unlinked)
 {
     this.first = first;
      this.second = second;
      this.segment = segment;
      this.connectorState = connectorState;
 }
コード例 #20
0
        protected void OnStateChange(ConnectorState newState) {
            m_state = newState;

            ConnectorStateHandler handler = StateChanged;
            if (handler != null) handler(this, m_state);
        }
コード例 #21
0
 public PgConnector(ArrayPool <byte> arrayPool)
 {
     m_arrayPool      = arrayPool;
     m_connectorState = ConnectorState.Disconnected;
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: ItzWarty/AdventuresInShade
 public void Connect()
 {
     connectorState = ConnectorState.Linked;
 }
コード例 #23
0
ファイル: Program.cs プロジェクト: ItzWarty/AdventuresInShade
 public void Disconnect()
 {
     connectorState = ConnectorState.Unlinked;
 }
コード例 #24
0
 protected void ChangeState(ConnectorState newState)
 {
     AssertNotDisposed();
     CurrentState = newState;
 }
 internal NpgsqlOperationInProgressException(ConnectorState state)
     : base($"The connection is already in state '{state}'")
 {
 }
コード例 #26
0
ファイル: Connector.cs プロジェクト: hexu6788/HSQL
 public void SetState(ConnectorState state)
 {
     _state = state;
 }
コード例 #27
0
 /// <summary>Changes the connector state</summary>
 /// <remarks>
 /// It's a convenience method. The caller can change the state of the connector state machine
 /// instead.
 /// </remarks>
 /// <param name="newState">The new state.</param>
 /// <seealso cref="connectorStateMachine"/>
 /// <seealso cref="connectorState"/>
 protected void SetConnectorState(ConnectorState newState)
 {
     connectorStateMachine.currentState = newState;
 }
コード例 #28
0
ファイル: Connector.cs プロジェクト: hexu6788/HSQL
 public void Dispose()
 {
     _state = ConnectorState.可用;
 }
コード例 #29
0
 private void changeStateTo(ConnectorState state)
 {
     connectionState = state;
     Debug.Log(TAG + "New state: " + connectionState);
 }
コード例 #30
0
 public ConnectorState UpdateConnectorState(ConnectorState state)
 {
     throw new NotImplementedException();
 }