Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Renamed CloseSession to just Close to match standard conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
DJGosnell committed Aug 30, 2016
1 parent cb6a2ac commit 7955b9f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DtronixMessageQueue.Tests/MqClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void Client_notified_server_session_closed() {
Server.Connected += (sender, session) => {
//Thread.Sleep(1000);
//session.Session.Send(new MqMessage(new MqFrame(new byte[24], MqFrameType.Last)));
session.Session.CloseConnection(SocketCloseReason.ApplicationError);
session.Session.Close(SocketCloseReason.ApplicationError);
};

Client.Closed += (sender, args) => {
Expand Down
2 changes: 1 addition & 1 deletion DtronixMessageQueue/MqClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void Send(MqMessage message) {

public void Close() {
Session.IncomingMessage -= OnIncomingMessage;
Session.CloseConnection(SocketCloseReason.ClientClosing);
Session.Close(SocketCloseReason.ClientClosing);
Session.Dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion DtronixMessageQueue/MqServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void TimeoutCallback(object state) {

foreach (var session in ConnectedSessions.Values) {
if (session.LastReceived < timeout_time) {
session.CloseConnection(SocketCloseReason.TimeOut);
session.Close(SocketCloseReason.TimeOut);
}
}

Expand Down
8 changes: 4 additions & 4 deletions DtronixMessageQueue/MqSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ internal void ProcessIncomingQueue() {
} catch (InvalidDataException) {
//logger.Error(ex, "Connector {0}: Client send invalid data.", Connection.Id);

CloseConnection(SocketCloseReason.ProtocolError);
Close(SocketCloseReason.ProtocolError);
break;
}

Expand Down Expand Up @@ -202,7 +202,7 @@ internal void ProcessIncomingQueue() {
}


public override void CloseConnection(SocketCloseReason reason) {
public override void Close(SocketCloseReason reason) {
if (CurrentState == State.Closed) {
return;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public override void CloseConnection(SocketCloseReason reason) {
ProcessOutbox();
}

base.CloseConnection(reason);
base.Close(reason);
}

/// <summary>
Expand Down Expand Up @@ -266,7 +266,7 @@ protected virtual void ProcessCommand(MqFrame frame) {
switch (command_type) {
case 0: // Closed
CurrentState = State.Closing;
CloseConnection((SocketCloseReason)frame.ReadByte(1));
Close((SocketCloseReason)frame.ReadByte(1));
break;

}
Expand Down
2 changes: 1 addition & 1 deletion DtronixMessageQueue/Socket/SocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void Stop() {
ConnectedSessions.Values.CopyTo(sessions, 0);

foreach (var session in sessions) {
session.CloseConnection(SocketCloseReason.ServerClosing);
session.Close(SocketCloseReason.ServerClosing);
}

MainSocket.Close();
Expand Down
16 changes: 8 additions & 8 deletions DtronixMessageQueue/Socket/SocketSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected virtual void IoCompleted(object sender, SocketAsyncEventArgs e) {
break;

case SocketAsyncOperation.Disconnect:
CloseConnection(SocketCloseReason.ClientClosing);
Close(SocketCloseReason.ClientClosing);
break;

case SocketAsyncOperation.Receive:
Expand Down Expand Up @@ -228,7 +228,7 @@ protected void Send(byte[] buffer, int offset, int length) {
IoCompleted(this, send_args);
}
} catch (ObjectDisposedException) {
CloseConnection(SocketCloseReason.SocketError);
Close(SocketCloseReason.SocketError);
}
}

Expand All @@ -240,7 +240,7 @@ protected void Send(byte[] buffer, int offset, int length) {
/// <param name="e">Event args of this action.</param>
private void SendComplete(SocketAsyncEventArgs e) {
if (e.SocketError != SocketError.Success) {
CloseConnection(SocketCloseReason.SocketError);
Close(SocketCloseReason.SocketError);
}
write_reset.Set();
}
Expand All @@ -265,7 +265,7 @@ protected void RecieveComplete(SocketAsyncEventArgs e) {

// If the bytes received is larger than the buffer, close this session.
//if (e.BytesTransferred > config.SendAndReceiveBufferSize) {
// CloseConnection(SocketCloseReason.SocketError);
// Close(SocketCloseReason.SocketError);
//}

// Create a copy of these bytes.
Expand All @@ -283,20 +283,20 @@ protected void RecieveComplete(SocketAsyncEventArgs e) {
IoCompleted(this, e);
}
} catch (ObjectDisposedException) {
CloseConnection(SocketCloseReason.SocketError);
Close(SocketCloseReason.SocketError);
}


} else {
CloseConnection(SocketCloseReason.SocketError);
Close(SocketCloseReason.SocketError);
}
}

/// <summary>
/// Called when this session is desired or requested to be closed.
/// </summary>
/// <param name="reason">Reason this socket is closing.</param>
public virtual void CloseConnection(SocketCloseReason reason) {
public virtual void Close(SocketCloseReason reason) {
// If this session has already been closed, nothing more to do.
if (CurrentState == State.Closed) {
return;
Expand Down Expand Up @@ -328,7 +328,7 @@ public virtual void CloseConnection(SocketCloseReason reason) {
/// </summary>
public void Dispose() {
if (CurrentState == State.Connected) {
CloseConnection(SocketCloseReason.ClientClosing);
Close(SocketCloseReason.ClientClosing);
}
}
}
Expand Down

0 comments on commit 7955b9f

Please sign in to comment.