Skip to content

Commit

Permalink
Rewrite QBasicConnection.Open() and QBasicConnection.Close() methods …
Browse files Browse the repository at this point in the history
…to use QBasicConnection.IsConnected() instead of null check
  • Loading branch information
maciejlach committed Sep 1, 2014
1 parent b5c8860 commit 9c82871
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qSharp/src/QBasicConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public QBasicConnection(String host = "localhost", int port = 0, string username
/// </summary>
virtual public void Open()
{
if (connection == null)
if (!IsConnected())
{
if (Host != null)
{
Expand Down Expand Up @@ -123,7 +123,7 @@ private void Initialize()
/// </summary>
virtual public void Close()
{
if (connection != null)
if (IsConnected())
{
connection.Close();
connection = null;
Expand All @@ -144,9 +144,9 @@ virtual public void Reset()
}

/// <summary>
/// Check whether connection with the remote q host has been established.
/// Check whether connection with the remote q host has been established and is active.
/// </summary>
/// <returns>true if connection with remote host is established, false otherwise</returns>
/// <returns>true if connection with remote host is established and is active, false otherwise</returns>
public bool IsConnected()
{
return connection != null && connection.Connected && connection.Client.Connected
Expand Down

0 comments on commit 9c82871

Please sign in to comment.