rest_websocket

package
v1.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt64

func BytesToInt64(bytes []byte) int64

BytesToInt64 конвертирует срез байтов в int64

func Int64ToBytes

func Int64ToBytes(num int64, byteCount int) []byte

Int64ToBytes упаковывает int64 в срез байтов заданной длины

func ReadBuf

func ReadBuf(r io.Reader, size int, field string) ([]byte, rest.IErrorArgs)

func ReadBufSize

func ReadBufSize(r io.Reader, lenSize int, field string) ([]byte, rest.IErrorArgs)

func ReadByte

func ReadByte(r io.Reader, field string, result *byte) rest.IErrorArgs

func ReadInt64

func ReadInt64(r io.Reader, size int, field string, result *int64) rest.IErrorArgs

func ReadString

func ReadString(r io.Reader, lenSize int, field string, result *string) rest.IErrorArgs

func WriteBuf

func WriteBuf(w io.Writer, buf []byte, field string) rest.IErrorArgs

func WriteBufSize

func WriteBufSize(w io.Writer, val []byte, lenSize int, field string) rest.IErrorArgs

func WriteByte

func WriteByte(w io.Writer, val byte, field string) rest.IErrorArgs

func WriteInt64

func WriteInt64(w io.Writer, val int64, size int, field string) rest.IErrorArgs

func WriteString

func WriteString(w io.Writer, val, field string, lenSize int) rest.IErrorArgs

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(ctx context.Context) *Application

func (*Application) Connect

func (s *Application) Connect() chan<- *SocketServer

func (*Application) Disconnect

func (s *Application) Disconnect() chan<- *SocketServer

type RequestIn

type RequestIn struct {
	*rest.RequestStream
	// contains filtered or unexported fields
}

func (*RequestIn) Auth

func (s *RequestIn) Auth() json.Map

func (*RequestIn) ClientData

func (s *RequestIn) ClientData(key string) (any, bool)

func (*RequestIn) GenerateToken

func (s *RequestIn) GenerateToken(data json.Map, expire int64) (string, error)

func (*RequestIn) OutError

func (s *RequestIn) OutError(err rest.IErrorArgs) rest.IRequestOut

func (*RequestIn) OutSuccess

func (s *RequestIn) OutSuccess(data json.Map, files rest.RequestFiles) rest.IRequestOut

func (*RequestIn) ParseToken added in v1.7.0

func (s *RequestIn) ParseToken(tokenString string) (json.Map, error)

func (*RequestIn) RCore

func (s *RequestIn) RCore() any

func (*RequestIn) ROwner

func (s *RequestIn) ROwner() rest.IOwner

func (*RequestIn) SetAuth

func (s *RequestIn) SetAuth(auth json.Map)

func (*RequestIn) SetClientData

func (s *RequestIn) SetClientData(key string, data any)

type Rest

type Rest struct {
	// contains filtered or unexported fields
}

func New

func New(app rest.IApplicationStream, core any) *Rest

func (*Rest) Prepare

func (s *Rest) Prepare(server rest.IServer, httpPrefix string)

type Socket

type Socket struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string) (*Socket, error)

func NewSocket

func NewSocket(conn *websocket.Conn, pingEnable bool) *Socket

func (*Socket) Close

func (s *Socket) Close()

func (*Socket) Context

func (s *Socket) Context() context.Context

func (*Socket) MessagesIn

func (s *Socket) MessagesIn() <-chan *rest.RequestStream

MessagesIn возвращает канал, в который будут переданы все входящие сообщения (rest.RequestTypeMessage и rest.RequestTypeEvent)

func (*Socket) SendMessage

func (s *Socket) SendMessage(req *rest.RequestStream) (ch <-chan *rest.RequestStream, err error)

type SocketServer

type SocketServer struct {
	// contains filtered or unexported fields
}

func NewSocketServer

func NewSocketServer(socket *Socket, appConf *appConfig) *SocketServer

func (*SocketServer) Auth

func (s *SocketServer) Auth() json.Map

func (*SocketServer) ClientData

func (s *SocketServer) ClientData(key string) (any, bool)

func (*SocketServer) Close

func (s *SocketServer) Close()

func (*SocketServer) Context

func (s *SocketServer) Context() context.Context

func (*SocketServer) In

func (s *SocketServer) In() <-chan rest.IRequestIn

func (*SocketServer) IsStream

func (s *SocketServer) IsStream() bool

func (*SocketServer) SendMessage

func (s *SocketServer) SendMessage(req rest.IRequestOut) (<-chan *rest.RequestStream, error)

func (*SocketServer) SetAuth

func (s *SocketServer) SetAuth(auth json.Map)

func (*SocketServer) SetClientData

func (s *SocketServer) SetClientData(key string, data any)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL