Documentation
¶
Index ¶
- func ParseRequest(data []byte) (any, error)
- func ParseResponse(data []byte) (any, error)
- func ShallowSleep(ctx context.Context, d time.Duration, signalChan chan any)
- type ClientConnectionStatusCallback
- type Event
- type EventPublishRequest
- type EventPublishResponse
- type EventSink
- type EventSource
- type EventSourcePullingRequest
- type EventSourcePullingResponse
- type EventType
- type NoStrClientSubscriptionFilter
- type NostrClient
- type NostrClientOption
- func NostrClientWithConnectionStatusCallback(callback ClientConnectionStatusCallback) NostrClientOption
- func NostrClientWithEventSink(sink EventSink) NostrClientOption
- func NostrClientWithServerURL(serverUrl string) NostrClientOption
- func NostrClientWithTLSConfig(tlsConfig *tls.Config) NostrClientOption
- type NostrClientOutputMsg
- type NostrClientStub
- type NostrClientSubscription
- type NostrServer
- type NostrServerOption
- func NostrServerAddress(address string) NostrServerOption
- func NostrServerTLS(tlsConfig *tls.Config) NostrServerOption
- func NostrServerWithEventSink(sink EventSink) NostrServerOption
- func NostrServerWithEventSource(source EventSource) NostrServerOption
- func NostrServerWithIdentity(identity string) NostrServerOption
- type RelayClient
- type RelayServer
- type RelayServerIdentifyResponse
- type RelayServerNotice
- type Request
- type Response
- type SubscribeRequest
- type SubscribeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRequest ¶
ParseRequest parses a request from the client. The return value can be:
Publish Subscribe
func ParseResponse ¶
ParseResponse parses a response from the server. The return value can be:
EventPublishResponse RelayServerIdentifyResponse SubscribeResponse RelayServerNotice
Types ¶
type ClientConnectionStatusCallback ¶
type ClientConnectionStatusCallback func(ctx context.Context, cancelFunc context.CancelCauseFunc, client RelayClient, serverIdentity string, status bool)
ClientConnectionStatusCallback is a callback function that is called when the connection status of the client changes. The implementation note:
- The callback function is called in a goroutine.
- Use *cancelFunc* to notify the caller there is something wrong of the callback. The caller should handle it.
- cancelFunc can be nil.
type EventPublishRequest ¶
type EventPublishRequest struct { RequestID string `json:"request_id,omitempty"` Type int `json:"type"` Data []byte `json:"data"` }
EventPublishRequest is a request from the client to publish an event to the relay server.
type EventPublishResponse ¶
type EventSource ¶
type EventSource func(ctx context.Context, request EventSourcePullingRequest) (EventSourcePullingResponse, error)
type NostrClient ¶
func NewNostrClient ¶
func NewNostrClient(opts ...NostrClientOption) *NostrClient
func (*NostrClient) Close ¶
func (c *NostrClient) Close() error
type NostrClientOption ¶
type NostrClientOption func(s *NostrClient)
func NostrClientWithConnectionStatusCallback ¶
func NostrClientWithConnectionStatusCallback(callback ClientConnectionStatusCallback) NostrClientOption
func NostrClientWithEventSink ¶
func NostrClientWithEventSink(sink EventSink) NostrClientOption
func NostrClientWithServerURL ¶
func NostrClientWithServerURL(serverUrl string) NostrClientOption
func NostrClientWithTLSConfig ¶
func NostrClientWithTLSConfig(tlsConfig *tls.Config) NostrClientOption
type NostrClientOutputMsg ¶
type NostrClientOutputMsg struct {
// contains filtered or unexported fields
}
type NostrClientStub ¶
type NostrClientStub struct {
// contains filtered or unexported fields
}
NostrClientStub is a presentation of a client connection to the relay server.
func (*NostrClientStub) Run ¶
func (c *NostrClientStub) Run()
type NostrClientSubscription ¶
type NostrServer ¶
type NostrServer struct {
// contains filtered or unexported fields
}
func NewNostrServer ¶
func NewNostrServer(opts ...NostrServerOption) *NostrServer
func (*NostrServer) Close ¶
func (s *NostrServer) Close() error
func (*NostrServer) ListenAndServe ¶
func (s *NostrServer) ListenAndServe() error
func (*NostrServer) ServeHTTP ¶
func (s *NostrServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type NostrServerOption ¶
type NostrServerOption func(s *NostrServer)
func NostrServerAddress ¶
func NostrServerAddress(address string) NostrServerOption
func NostrServerTLS ¶
func NostrServerTLS(tlsConfig *tls.Config) NostrServerOption
func NostrServerWithEventSink ¶
func NostrServerWithEventSink(sink EventSink) NostrServerOption
func NostrServerWithEventSource ¶
func NostrServerWithEventSource(source EventSource) NostrServerOption
func NostrServerWithIdentity ¶
func NostrServerWithIdentity(identity string) NostrServerOption
type RelayClient ¶
type RelayServer ¶
type RelayServerIdentifyResponse ¶
type RelayServerIdentifyResponse struct {
Identity string `json:"identify"`
}
type RelayServerNotice ¶
type RelayServerNotice struct {
Message string `json:"message"`
}
type Request ¶
type Request struct { Publish *EventPublishRequest `json:"publish,omitempty"` Subscribe *SubscribeRequest `json:"subscribe,omitempty"` }
Request is a request to the relay server.
type Response ¶
type Response struct { RelayServerIdentifyResponse *RelayServerIdentifyResponse `json:"identify_response,omitempty"` SubscribeResponse *SubscribeResponse `json:"subscribe_response,omitempty"` EventPublishResponse *EventPublishResponse `json:"publish_response,omitempty"` Notice *RelayServerNotice `json:"notice,omitempty"` }
Response is a message from the relay server.
type SubscribeRequest ¶
type SubscribeRequest struct { SubscribeID string `json:"subscribe_id,omitempty"` Type int `json:"type"` Offset int64 `json:"offset"` }
SubscribeRequest is a request from the client to subscribe an event from the relay server.
type SubscribeResponse ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.