ask

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asker

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

func (*Asker) Connect

func (a *Asker) Connect(index int32) error

func (*Asker) GetAddress

func (a *Asker) GetAddress() (string, int32)

func (*Asker) Handler

func (a *Asker) Handler()

TODO: 區分 1. 使用心跳機制維持連線的版本() 2. 根據 RFC 2616 (page 46) 的標準定義,單個客戶端不允許開啟 2 個以上的長連接,這個標準的目的是減少 HTTP 響應的時候,減少網絡堵塞。

type HttpAsker

type HttpAsker struct {
	*Asker

	// 依序處理請求
	Handlers map[int32]ghttp.HandlerFunc
	// contains filtered or unexported fields
}

func (*HttpAsker) Connect

func (a *HttpAsker) Connect() error

func (*HttpAsker) NewRequest

func (a *HttpAsker) NewRequest(method string, uri string, params map[string]string) *ghttp.Request

func (*HttpAsker) Send

func (a *HttpAsker) Send(req *ghttp.Request, callback func(*ghttp.Context)) error

供外部傳送 Http 請求

func (*HttpAsker) SetWorkHandler

func (a *HttpAsker) SetWorkHandler()

[Work State: 1] 由外部定義 workHandler,定義如何處理工作

func (*HttpAsker) Write

func (a *HttpAsker) Write(data *[]byte, length int32) error

原始數據寫出函式,缺乏定義 Callback 函式的能力,應使用 Send 來傳送請求

type IAsker

type IAsker interface {
	// 開始連線
	Connect() error
	// 執行一次主迴圈
	Handler()
	// 取得連線位置
	GetAddress() (string, int32)
	// 供外部寫出數據(寫到寫出緩存中)
	Write(*[]byte, int32) error
}

func NewAsker

func NewAsker(socketType define.SocketType, site int32, laddr *net.TCPAddr, nWork int32, onEvents base.OnEventsFunc, introduction *[]byte, heartbeat *[]byte) (IAsker, error)

func NewHttpAsker

func NewHttpAsker(site int32, laddr *net.TCPAddr, nConnect int32, nWork int32) (IAsker, error)

func NewTcp0Asker

func NewTcp0Asker(site int32, laddr *net.TCPAddr, nConnect int32, nWork int32, onEvents base.OnEventsFunc, introduction *[]byte, heartbeat *[]byte) (IAsker, error)

type Tcp0Asker

type Tcp0Asker struct {
	*Asker
	// contains filtered or unexported fields
}

func (*Tcp0Asker) Connect

func (a *Tcp0Asker) Connect() error

func (*Tcp0Asker) SetWorkHandler

func (a *Tcp0Asker) SetWorkHandler(handler func(*base.Work))

由外部定義 workHandler,定義如何處理工作

func (*Tcp0Asker) Write

func (a *Tcp0Asker) Write(data *[]byte, length int32) error

供外部寫出數據

Jump to

Keyboard shortcuts

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