// Copyright 2012-2025 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Adapted from server/client.go (subscription struct) in the NATS server Go source.
namespace ZB.MOM.NatsNet.Server.Internal;
///
/// Represents a client subscription in the NATS server.
/// Mirrors the Go subscription struct from client.go.
/// This is a minimal stub; full client integration will be added in later sessions.
///
public sealed class Subscription
{
/// The subject this subscription is listening on.
public byte[] Subject { get; set; } = [];
/// The queue group name, or null/empty for non-queue subscriptions.
public byte[]? Queue { get; set; }
/// The subscription identifier.
public byte[]? Sid { get; set; }
/// Queue weight for remote queue subscriptions.
public int Qw;
/// Closed flag (0 = open, 1 = closed).
private int _closed;
/// The client that owns this subscription. Null in test/stub scenarios.
public NatsClient? Client { get; set; }
/// Marks this subscription as closed.
public void Close() => Interlocked.Exchange(ref _closed, 1);
/// Returns true if this subscription has been closed.
public bool IsClosed() => Interlocked.CompareExchange(ref _closed, 0, 0) == 1;
}
///
/// Represents the kind of client connection.
/// Mirrors Go's clientKind enum.
/// This is a minimal stub; full implementation in later sessions.
///
public enum ClientKind
{
Client = 0,
Router = 1,
Gateway = 2,
System = 3,
Leaf = 4,
JetStream = 5,
Account = 6,
}
///
/// Minimal client stub for subscription routing.
/// Full implementation will be added in later sessions.
///
public class NatsClient
{
/// The kind of client connection.
public ClientKind Kind { get; set; }
/// Whether this is a hub leaf node. Stub for now.
public virtual bool IsHubLeafNode() => false;
}