notify/servertype.go

110 lines
5.6 KiB
Go
Raw Normal View History

2021-11-12 16:04:39 +08:00
package notify
import (
"context"
"net"
"time"
)
type Server interface {
// Deprecated: SetDefaultCommEncode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
2021-11-12 16:04:39 +08:00
SetDefaultCommEncode(func([]byte, []byte) []byte)
// Deprecated: SetDefaultCommDecode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
2021-11-12 16:04:39 +08:00
SetDefaultCommDecode(func([]byte, []byte) []byte)
SetDefaultLink(func(message *Message))
SetLink(string, func(*Message))
SetFileHandler(func(FileEvent))
SetStreamHandler(func(StreamAcceptInfo) error)
SetRecordStreamHandler(func(RecordAcceptInfo) error)
SetBulkHandler(func(BulkAcceptInfo) error)
SetTransferHandler(func(TransferAcceptInfo) (TransferReceiveOptions, error))
GetStreamConfig() StreamConfig
SetStreamConfig(StreamConfig)
SetTransferResumeStore(TransferResumeStore)
RecoverTransferSnapshots(context.Context) error
SetFileReceiveDir(dir string) error
2021-11-12 16:04:39 +08:00
send(c *ClientConn, msg TransferMsg) (WaitMsg, error)
sendEnvelope(c *ClientConn, env Envelope) error
2021-11-12 16:04:39 +08:00
sendWait(c *ClientConn, msg TransferMsg, timeout time.Duration) (Message, error)
OpenStreamLogical(ctx context.Context, c *LogicalConn, opt StreamOpenOptions) (Stream, error)
OpenStreamTransport(ctx context.Context, t *TransportConn, opt StreamOpenOptions) (Stream, error)
OpenRecordStreamLogical(ctx context.Context, c *LogicalConn, opt RecordOpenOptions) (RecordStream, error)
OpenRecordStreamTransport(ctx context.Context, t *TransportConn, opt RecordOpenOptions) (RecordStream, error)
OpenBulkLogical(ctx context.Context, c *LogicalConn, opt BulkOpenOptions) (Bulk, error)
OpenBulkTransport(ctx context.Context, t *TransportConn, opt BulkOpenOptions) (Bulk, error)
SendTransferLogical(ctx context.Context, c *LogicalConn, opt TransferSendOptions) (TransferHandle, error)
SendTransferTransport(ctx context.Context, t *TransportConn, opt TransferSendOptions) (TransferHandle, error)
SendObjCtxLogical(ctx context.Context, c *LogicalConn, key string, val interface{}) (Message, error)
SendObjLogical(c *LogicalConn, key string, val interface{}) error
SendLogical(c *LogicalConn, key string, value MsgVal) error
SendWaitLogical(c *LogicalConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjLogical(c *LogicalConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxLogical(ctx context.Context, c *LogicalConn, key string, value MsgVal) (Message, error)
SendObjCtxTransport(ctx context.Context, t *TransportConn, key string, val interface{}) (Message, error)
SendObjTransport(t *TransportConn, key string, val interface{}) error
SendTransport(t *TransportConn, key string, value MsgVal) error
SendWaitTransport(t *TransportConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjTransport(t *TransportConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxTransport(ctx context.Context, t *TransportConn, key string, value MsgVal) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
2021-11-12 16:04:39 +08:00
SendObjCtx(ctx context.Context, c *ClientConn, key string, val interface{}) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
2021-11-12 16:04:39 +08:00
SendObj(c *ClientConn, key string, val interface{}) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
2021-11-12 16:04:39 +08:00
Send(c *ClientConn, key string, value MsgVal) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
2021-11-12 16:04:39 +08:00
SendWait(c *ClientConn, key string, value MsgVal, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
2022-01-07 15:07:24 +08:00
SendWaitObj(c *ClientConn, key string, value interface{}, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
2021-11-12 16:04:39 +08:00
SendCtx(ctx context.Context, c *ClientConn, key string, value MsgVal) (Message, error)
Reply(m Message, value MsgVal) error
pushMessage([]byte, string)
removeLogical(logical *LogicalConn)
2021-11-12 16:04:39 +08:00
removeClient(client *ClientConn)
Listen(network string, addr string) error
ListenByListener(listener net.Listener) error
2021-11-12 16:04:39 +08:00
Stop() error
StopMonitorChan() <-chan struct{}
Status() Status
GetSecretKey() []byte
// Deprecated: SetSecretKey injects a raw transport key directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
2021-11-12 16:04:39 +08:00
SetSecretKey(key []byte)
// Deprecated: RsaPrivKey exposes the legacy RSA handshake key. Prefer UseModernPSKServer.
2021-11-12 16:04:39 +08:00
RsaPrivKey() []byte
// Deprecated: SetRsaPrivKey configures the legacy RSA handshake key. Prefer UseModernPSKServer.
2021-11-12 16:04:39 +08:00
SetRsaPrivKey([]byte)
GetLogicalConn(id string) *LogicalConn
GetLogicalConnList() []*LogicalConn
GetCurrentTransportConn(id string) *TransportConn
GetCurrentTransportConnByLogical(c *LogicalConn) *TransportConn
GetCurrentTransportConnList() []*TransportConn
// Deprecated: prefer GetLogicalConn.
2021-11-12 16:04:39 +08:00
GetClient(id string) *ClientConn
// Deprecated: prefer GetLogicalConnList.
2021-11-12 16:04:39 +08:00
GetClientLists() []*ClientConn
GetClientAddrs() []net.Addr
2022-01-07 15:07:24 +08:00
GetSequenceEn() func(interface{}) ([]byte, error)
SetSequenceEn(func(interface{}) ([]byte, error))
2021-11-12 16:04:39 +08:00
GetSequenceDe() func([]byte) (interface{}, error)
SetSequenceDe(func([]byte) (interface{}, error))
2022-02-23 14:36:12 +08:00
ShowError(bool)
2022-05-20 09:27:19 +08:00
DebugMode(bool)
IsDebugMode() bool
2021-11-12 16:04:39 +08:00
2022-01-07 15:07:24 +08:00
HeartbeatTimeoutSec() int64
2021-11-12 16:04:39 +08:00
SetHeartbeatTimeoutSec(int64)
DetachedClientKeepSec() int64
SetDetachedClientKeepSec(int64)
SendFileLogical(ctx context.Context, c *LogicalConn, filePath string) error
SendFileTransport(ctx context.Context, t *TransportConn, filePath string) error
// Deprecated: prefer SendFileLogical or SendFileTransport.
SendFile(ctx context.Context, c *ClientConn, filePath string) error
2021-11-12 16:04:39 +08:00
}