chat

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Information *map[string]interface{}
	Locale      string
	Token       string
	Connection  *websocket.Conn
	Channel     chan string
}

A Client will connect to the Olivia's server using the Token the Information and the Locale

func NewClient

func NewClient(host string, ssl bool, information *map[string]interface{}) (client Client, err error)

NewClient creates a new Client by generating a random token, and setting english as the default langauge. You need to give a pointer of the information map of your client. The host is also required with a boolean, if the SSL certificate is required.

func (*Client) Close

func (client *Client) Close()

Close closes the websocket connection

func (*Client) SendMessage

func (client *Client) SendMessage(content string) (ResponseMessage, error)

SendMessage sends the given content to the websocket of Olivia and returns her response with an error.

type RequestMessage

type RequestMessage struct {
	Type        int                    `json:"type"` // 0 for handshakes and 1 for messages
	Content     string                 `json:"content"`
	Token       string                 `json:"user_token"`
	Information map[string]interface{} `json:"information"`
	Locale      string                 `json:"locale"`
}

RequestMessage is the structure that uses entry connections to chat with the websocket

type ResponseMessage

type ResponseMessage struct {
	Content     string                 `json:"content"`
	Tag         string                 `json:"tag"`
	Information map[string]interface{} `json:"information"`
	Data        map[string]interface{} `json:"data"`
}

ResponseMessage is the structure used to reply to the user through the websocket

Jump to

Keyboard shortcuts

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