part

package
v0.28.20240422183953 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSerIsNil  = errors.New("ErrSerIsNil")
	ErrFileNoSet = errors.New("ErrFileNoSet")
	ErrhadStart  = errors.New("ErrhadStart")
	ErrIsExist   = errors.New("ErrIsExist")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Url string

	TO     int
	Header map[string]string
	Proxy  string

	Ping Ping

	Msg_normal_close  string
	Func_normal_close func()
	Func_abort_close  func()
	// contains filtered or unexported fields
}

func New_client

func New_client(config *Client) (*Client, error)

func (*Client) Close

func (o *Client) Close()

func (*Client) Error

func (o *Client) Error() (e error)

func (*Client) Handle

func (o *Client) Handle() (*msgq.MsgType[*WsMsg], error)

处理

msg.PushLock_tag(`send`, &WsMsg{
	Msg:  []byte("message"),
})

msg.Pull_tag_only(`rec`, func(wm *WsMsg) (disable bool) {
	fmt.Println(string(wm.Msg))
	return false
})

事件 send rec close exit

func (*Client) Heartbeat

func (o *Client) Heartbeat() (err error)

func (*Client) Isclose

func (o *Client) Isclose() (isclose bool)

type Ping

type Ping struct {
	Msg    []byte
	Period int
	// contains filtered or unexported fields
}

type Recorder added in v0.10.0

type Recorder struct {
	Server *Server
	// contains filtered or unexported fields
}

func (*Recorder) Start added in v0.10.0

func (t *Recorder) Start(filePath string) error

func (*Recorder) Stop added in v0.10.0

func (t *Recorder) Stop()

type Server added in v0.3.9

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

func New_server added in v0.3.9

func New_server() *Server

func Play added in v0.10.0

func Play(filePath string) (s *Server, close func())

func (*Server) Interface added in v0.3.9

func (t *Server) Interface() *mq.Msgq

how to use

ws_mq.Pull_tag(map[string]func(interface{})(bool){
	`recv`:func(data interface{})(bool){
		if tmp,ok := data.(Uinterface);ok {
			log.Println(tmp.Id,string(tmp.Data))

			if string(tmp.Data) == `close` {
				ws_mq.Push_tag(`close`,Uinterface{//close
					Id:0,//close all connect
				})
				//or
				// ws_mq.Push_tag(`close`,Uinterface{//close
				// 	Id:tmp.Id,//close this connect
				// })
				return false
			}

				ws_mq.Push_tag(`send`,Uinterface{//just reply
					Id:tmp.Id,
					Data:tmp.Data,
				})
				//or
				ws_mq.Push_tag(`send`,Uinterface{//just reply
					Id:0,//send to all
					Data:tmp.Data,
				})
			}
			return false
		},
		`error`:func(data interface{})(bool){
			log.Println(data)
			return false
		},
	})

func (*Server) Len added in v0.3.9

func (t *Server) Len() int64

func (*Server) WS added in v0.3.9

func (t *Server) WS(w http.ResponseWriter, r *http.Request) (o chan uintptr)

type Uinterface added in v0.3.9

type Uinterface struct {
	Id   uintptr
	Data []byte
}

type WsMsg added in v0.26.0

type WsMsg struct {
	Type int
	Msg  []byte
}

Jump to

Keyboard shortcuts

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