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

Commit

Permalink
Isolated socket from MQ implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
DJGosnell committed Sep 13, 2016
1 parent 229d0bb commit 13cbe86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 9 additions & 0 deletions DtronixMessageQueue/MqSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public abstract class MqSession<TSession> : SocketSession
/// </summary>
private MqMessage message;

/// <summary>
/// Internal framebuilder for this instance.
/// </summary>
private MqFrameBuilder frame_builder;

/// <summary>
/// Outbox message queue. Internally used to store Messages before being sent to the wire by the Postmaster.
/// </summary>
Expand All @@ -53,6 +58,10 @@ public abstract class MqSession<TSession> : SocketSession
/// </summary>
public SocketBase<TSession> BaseSocket { get; set; }

protected override void OnSetup() {
frame_builder = new MqFrameBuilder((MqSocketConfig)Config);
}

/// <summary>
/// Adds bytes from the client/server reading methods to be processed by the Postmaster.
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions DtronixMessageQueue/Socket/SocketSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,17 @@ public enum State : byte {
/// </summary>
public State CurrentState { get; protected set; }


/// <summary>
/// Internal framebuilder for this instance.
/// The last time that this session received a message.
/// </summary>
protected MqFrameBuilder frame_builder;

private DateTime last_received = DateTime.UtcNow;

/// <summary>
/// Last time the session received anything from the socket. Time in UTC.
/// </summary>
public DateTime LastReceived => last_received;

protected System.Net.Sockets.Socket socket;
private System.Net.Sockets.Socket socket;

/// <summary>
/// Raw socket for this session.
Expand Down Expand Up @@ -132,7 +129,6 @@ public static void Setup(SocketSession session, System.Net.Sockets.Socket socket
session.send_args.Completed += session.IoCompleted;
session.receive_args = args_pool.Pop();
session.receive_args.Completed += session.IoCompleted;
session.frame_builder = new MqFrameBuilder((MqSocketConfig)config);

session.socket = socket;
session.write_reset = new ManualResetEventSlim(true);
Expand Down

0 comments on commit 13cbe86

Please sign in to comment.