socket

package
v0.0.0-...-646cb8e Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicTableName        = "topics"
	AnswersTableName      = "answers"
	ConnectUsersTablename = "connectusers"
)

Variables

This section is empty.

Functions

func ReceiveHost

func ReceiveHost(ws *websocket.Conn, db *database.DatabaseOp, id string, quit chan bool)

Received a socket to the host.

Arguments:

ws {*websocket.Conn} - websocket operator.
db {*database.DatabaseOp} - database op.
id {string} - id
quit {chan bool} - quit signal.

func ReceiveVisitor

func ReceiveVisitor(ws *websocket.Conn, db *database.DatabaseOp, id string, userId string, quit chan bool)

Received a socket to the visitor.

Arguments:

ws {*websocket.Conn} - websocket operator.
db {*database.DatabaseOp} - database op.
id {string} - id
quit {chan bool} - quit signal.

func SendHost

func SendHost(ws *websocket.Conn, db *database.DatabaseOp, id string, quit chan bool)

Send a socket to the host.

Arguments:

ws {*websocket.Conn} - websocket operator.
db {*database.DatabaseOp} - database op.
id {string} - id
quit {chan bool} - quit signal.

func SendVisitor

func SendVisitor(ws *websocket.Conn, db *database.DatabaseOp, id string, userId string, quit chan bool, topics *map[string]*string)

Send a socket to the visitor.

Arguments:

ws {*websocket.Conn} - websocket operator.
db {*database.DatabaseOp} - database op.
id {string} - id
userId {string} - user id
quit {chan bool} - quit signal.
topics {*map[string]*string} - topics.

func TopicGetter

func TopicGetter(db *database.DatabaseOp, topics *map[string]*string)

Types

type CloseSocket

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

func NewCloseSocket

func NewCloseSocket(ws *websocket.Conn, db *database.DatabaseOp, id string) *CloseSocket

Create close socket instance.

Arguments:

ws {*websocket.Conn} - websocket
db {*database.DatabaseOp} - database operator
id {string} - id.

func (*CloseSocket) Host

func (c *CloseSocket) Host() error

Close host.

  • delete topic for id.
  • delete answers for id.
  • delete connect users for id.

func (*CloseSocket) HostNoErr

func (c *CloseSocket) HostNoErr()

func (*CloseSocket) Visitor

func (c *CloseSocket) Visitor(userId string) error

Close visitor.

  • delete connect users for user id.

func (*CloseSocket) VisitorNoErr

func (c *CloseSocket) VisitorNoErr(userId string)

type InitializeSocket

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

func NewInitSocket

func NewInitSocket(ws *websocket.Conn, db *database.DatabaseOp) *InitializeSocket

Create initialize socket instance.

Arguments:

ws {*websocket.Conn} - websocket
db {*database.DatabaseOp} - database operator

func (*InitializeSocket) Host

func (c *InitializeSocket) Host() (string, error)

initialize host.

Returns:

{string} - id

func (*InitializeSocket) Visitor

func (c *InitializeSocket) Visitor() (string, string, error)

initialize visitor

Returns:

{string} - id.
{string} - user id.

type SendAnswers

type SendAnswers struct {
	SendType string            `json:"type"`
	Answers  []database.Answer `json:"answers"`
}

type Status

type Status int
const (
	Host    Status = iota
	Visitor        = iota
)

Jump to

Keyboard shortcuts

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