client

package
v0.0.0-...-b6ccf9b Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrorsServerError                 = errors.New("server error")
	ErrorMessageTypeProcessorIsExists = errors.New("this message type processor is Exists")
)
View Source
var (
	ErrorContentTypeIsUnknown = errors.New("content type is unknown")
)

Functions

This section is empty.

Types

type BaseWebsocketMessage

type BaseWebsocketMessage struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data"`
}

type Client

type Client struct {
	WebSocketConnection *websocket.Conn
	Wg                  *sync.WaitGroup
	ClientID            string

	UserID string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opt *ClientOption) (*Client, error)
Example

ExampleNewClient is a sample function to show how to use NewClient

opt := &ClientOption{
	Host:     "127.0.0.1",
	Port:     8818,
	Wg:       &sync.WaitGroup{},
	ClientID: uuid.New().String(),
}

c, err := NewClient(opt)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(c.ClientID)
Output:

61d52256-add9-4573-8b31-d27c92f6d8bb

func (*Client) CloseWebsocket

func (client *Client) CloseWebsocket() error

func (*Client) DownloadImage

func (client *Client) DownloadImage(info *websocket_message_model.Image) (string, []byte, error)

func (*Client) Extensions

func (client *Client) Extensions() ([]string, error)

func (*Client) GetUsers

func (client *Client) GetUsers() (*model.UserList, error)

func (*Client) Prompt

func (client *Client) Prompt(requestBody *model.PromptRequest) (*model.PromptResponse, error)

func (*Client) RegisterMessageProcessor

func (client *Client) RegisterMessageProcessor(messageType string, function func(message *BaseWebsocketMessage) error)

func (*Client) SelectUser

func (client *Client) SelectUser(userID string)

func (*Client) UploadImage

func (client *Client) UploadImage(filename string, body []byte) (*model.UpLoadImage, error)

func (*Client) UploadImageFile

func (client *Client) UploadImageFile(filename string) (*model.UpLoadImage, error)

func (*Client) Workflow

func (client *Client) Workflow(path string) (*model.WorkflowDetail, error)

func (*Client) WorkflowList

func (client *Client) WorkflowList() ([]*model.Workflow, error)

type ClientOption

type ClientOption struct {
	Host     string
	Port     int
	Logger   log.Logger
	Wg       *sync.WaitGroup
	ClientID string
}

type Input

type Input struct {
	Type  InputType
	Value any
}

func (*Input) GetValue

func (input *Input) GetValue() any

type InputType

type InputType string
const (
	InputTypeRandom InputType = "rand_int64"
	InputTypeString InputType = "string"
	InputTypeInt64  InputType = "int64"
)

Jump to

Keyboard shortcuts

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