using System.Net;
using System.Net.WebSockets;
using Nostr.Client.Messages;
using Nostr.Client.Requests;

namespace NostrRelay;

public record NostrClientContext(WebSocket WebSocket, IPAddress Ip, string UserAgent);
public record HandleEventResponse(bool Ok, string? Message);

public interface INostrRelay
{
    /// <summary>
    /// If we should handle this connection
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    ValueTask<bool> AcceptConnection(NostrClientContext context);

    /// <summary>
    /// Respond to a request for content
    /// </summary>
    /// <param name="context"></param>
    /// <param name="req"></param>
    /// <returns></returns>
    IAsyncEnumerable<NostrEvent> HandleRequest(NostrClientContext context, NostrRequest req);

    /// <summary>
    /// Handle new event publish
    /// </summary>
    /// <param name="context"></param>
    /// <param name="ev"></param>
    /// <returns></returns>
    ValueTask<HandleEventResponse> HandleEvent(NostrClientContext context, NostrEvent ev);
}
