server

package
v0.0.0-...-54cc154 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastSocketEventToAllClient

func BroadcastSocketEventToAllClient(hub *Hub, payload SocketEventStruct)

BroadcastSocketEventToAllClient will emit the socket events to all socket users

func CreateNewSocketUser

func CreateNewSocketUser(hub *Hub, connection *websocket.Conn, userId string, username, name string)

func EmitToSpecificClient

func EmitToSpecificClient(hub *Hub, payload SocketEventStruct, userID string)

EmitToSpecificClient will emit the socket event to specific socket user

func HandleUserDisconnectEvent

func HandleUserDisconnectEvent(hub *Hub, client *Client)

HandleUserDisconnectEvent will handle the Disconnect event for socket users

func HandleUserRegisterEvent

func HandleUserRegisterEvent(hub *Hub, client *Client)

HandleUserRegisterEvent will handle the Join event for New socket users

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

type Hub

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

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type JoinDisconnectPayload

type JoinDisconnectPayload struct {
	Users  []UserStruct `json:"users"`
	UserID string       `json:"userID"`
}

JoinDisconnectPayload will have struct for payload of join disconnect

type Server

type Server struct {
	Account accounts.Service
	Trello  trello.Service
	Inbox   handling.ServiceInbox

	Logger *log.Entry
	// contains filtered or unexported fields
}

func New

func New(account accounts.Service, trello trello.Service, handlingInbox handling.ServiceInbox, logger *log.Entry) *Server

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (s *Server) Start(addr, port string) error

type SocketEventStruct

type SocketEventStruct struct {
	EventName    string      `json:"eventName"`
	EventPayload interface{} `json:"eventPayload"`
}

SocketEventStruct struct of socket events

type TemplateRenderer

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

TemplateRenderer is a custom html/template renderer for Echo framework

func (*TemplateRenderer) Render

func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error

Render renders a template document

type UserStruct

type UserStruct struct {
	Username string `json:"username"`
	UserID   string `json:"userID"`
	Name     string `json:"name"`
}

UserStruct is used for sending users with socket id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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