refactoring from previous pr
This commit is contained in:
parent
408be48082
commit
fe45cb4beb
@ -122,8 +122,8 @@ export interface IncomingNotice {
|
|||||||
*/
|
*/
|
||||||
export type OutgoingMessage =
|
export type OutgoingMessage =
|
||||||
| OutgoingEvent
|
| OutgoingEvent
|
||||||
| OutgoingSubscription
|
| OutgoingOpenSubscription
|
||||||
| OutgoingUnsubscription
|
| OutgoingCloseSubscription
|
||||||
|
|
||||||
export const enum OutgoingKind {
|
export const enum OutgoingKind {
|
||||||
Event,
|
Event,
|
||||||
@ -140,18 +140,18 @@ export interface OutgoingEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outgoing "REQ" message, representing a subscription.
|
* Outgoing "REQ" message, which opens a subscription.
|
||||||
*/
|
*/
|
||||||
export interface OutgoingSubscription {
|
export interface OutgoingOpenSubscription {
|
||||||
kind: OutgoingKind.Subscription
|
kind: OutgoingKind.Subscription
|
||||||
id: SubscriptionId
|
id: SubscriptionId
|
||||||
filters: Filters
|
filters: Filters
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outgoing "CLOSE" message, representing an unsubscription.
|
* Outgoing "CLOSE" message, which closes a subscription.
|
||||||
*/
|
*/
|
||||||
export interface OutgoingUnsubscription {
|
export interface OutgoingCloseSubscription {
|
||||||
kind: OutgoingKind.Unsubscription
|
kind: OutgoingKind.Unsubscription
|
||||||
id: SubscriptionId
|
id: SubscriptionId
|
||||||
}
|
}
|
||||||
|
@ -12,24 +12,7 @@ export class Nostr {
|
|||||||
/**
|
/**
|
||||||
* Open connections to relays.
|
* Open connections to relays.
|
||||||
*/
|
*/
|
||||||
readonly #conns: Map<
|
readonly #conns: Map<string, ConnState> = new Map()
|
||||||
string,
|
|
||||||
{
|
|
||||||
conn: Conn
|
|
||||||
/**
|
|
||||||
* Has this connection been authenticated via NIP-44 AUTH?
|
|
||||||
*/
|
|
||||||
auth: boolean
|
|
||||||
/**
|
|
||||||
* Should this connection be used for receiving messages?
|
|
||||||
*/
|
|
||||||
read: boolean
|
|
||||||
/**
|
|
||||||
* Should this connection be used for publishing events?
|
|
||||||
*/
|
|
||||||
write: boolean
|
|
||||||
}
|
|
||||||
> = new Map()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of subscription IDs to corresponding filters.
|
* Mapping of subscription IDs to corresponding filters.
|
||||||
@ -236,6 +219,22 @@ export class Nostr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ConnState {
|
||||||
|
conn: Conn
|
||||||
|
/**
|
||||||
|
* Has this connection been authenticated via NIP-44 AUTH?
|
||||||
|
*/
|
||||||
|
auth: boolean
|
||||||
|
/**
|
||||||
|
* Should this connection be used for receiving messages?
|
||||||
|
*/
|
||||||
|
read: boolean
|
||||||
|
/**
|
||||||
|
* Should this connection be used for publishing events?
|
||||||
|
*/
|
||||||
|
write: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A string uniquely identifying a client subscription.
|
* A string uniquely identifying a client subscription.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user