-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace ActiveMQ.Artemis.Core.Client.Framing; | ||
|
||
internal class NullResponse : Packet | ||
{ | ||
public const byte Type = 68; | ||
|
||
public override void Encode(ByteBuffer buffer) | ||
{ | ||
} | ||
|
||
public override void Decode(ByteBuffer buffer) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace ActiveMQ.Artemis.Core.Client.Framing; | ||
|
||
internal class SessionStart : Packet | ||
{ | ||
public const byte Type = 67; | ||
|
||
public override void Encode(ByteBuffer buffer) | ||
{ | ||
} | ||
|
||
public override void Decode(ByteBuffer buffer) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace ActiveMQ.Artemis.Core.Client.Framing; | ||
|
||
internal class SessionStop : Packet | ||
{ | ||
public const byte Type = 68; | ||
|
||
public override void Encode(ByteBuffer buffer) | ||
{ | ||
} | ||
|
||
public override void Decode(ByteBuffer buffer) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,42 @@ | ||
using System.Collections.Concurrent; | ||
using ActiveMQ.Artemis.Core.Client.Framing; | ||
|
||
namespace ActiveMQ.Artemis.Core.Client; | ||
|
||
public interface ISession : IAsyncDisposable; | ||
|
||
internal class Session(Transport socket) : ISession | ||
internal class Session : ISession | ||
{ | ||
private readonly Transport _transport; | ||
|
||
private ConcurrentDictionary<long, TaskCompletionSource<Packet>> _completionSources = new(); | ||
|
||
public Session(Transport transport) | ||
{ | ||
_transport = transport; | ||
|
||
_ = Task.Run(async () => | ||
{ | ||
while (true) | ||
{ | ||
var packet = await _transport.ReceiveAsync(default); | ||
} | ||
}); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
await socket.DisposeAsync().ConfigureAwait(false); | ||
|
||
await _transport.SendAsync(new SessionStop(), ChannelId, default); | ||
|
||
await _transport.DisposeAsync().ConfigureAwait(false); | ||
} | ||
|
||
public long ChannelId { get; init; } | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
await _transport.SendAsync(new SessionStart(), ChannelId, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters