websocket_server

package
v0.1.3-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseWebsocketEventData

type BaseWebsocketEventData struct {
	EventName WebsocketEventType `json:"eventName"`
}

func (BaseWebsocketEventData) GetEventName

func (event BaseWebsocketEventData) GetEventName() string

type ConversationAssignmentEventData

type ConversationAssignmentEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		AssignedToMemberID string `json:"assignedToMemberId"`
		ConversationID     string `json:"conversationId"`
		AssignedAt         string `json:"assignedAt"`
	} `json:"data"`
}

type ConversationClosedEventData

type ConversationClosedEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		ConversationID string `json:"conversationId"`
	} `json:"data"`
}

type MessageAcknowledgementEventData

type MessageAcknowledgementEventData struct {
	Message string `json:"message"`
}

type MessageEventData

type MessageEventData struct {
	Message api_types.MessageSchema
}

type MessageReadEventData

type MessageReadEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		MessageID string `json:"messageId"`
	} `json:"data"`
}

type NewConversationEventData

type NewConversationEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		ConversationID string `json:"conversationId"`
	} `json:"data"`
}

type NewNotificationEventData

type NewNotificationEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		NotificationID string `json:"notificationId"`
	} `json:"data"`
}

type NotificationReadEventData

type NotificationReadEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		NotificationId string `json:"notificationId"`
	} `json:"data"`
}

type PingEventData

type PingEventData struct {
	Data string `json:"data"`
}

type SystemReloadEventData

type SystemReloadEventData struct {
	BaseWebsocketEventData `json:"-,inline"`
	Data                   struct {
		MessageText      string `json:"messageText"`
		MessageTitle     string `json:"messageTitle"`
		IsReloadRequired bool   `json:"isReloadRequired"`
	} `json:"data"`
}

type WebSocketServer

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

func InitWebsocketServer

func InitWebsocketServer(app *interfaces.App, wg *sync.WaitGroup) *WebSocketServer

func (*WebSocketServer) HandleApiServerEvents

func (server *WebSocketServer) HandleApiServerEvents(ctx context.Context, app interfaces.App)

NOTE: we are following a one way data flow for ApiServerEvent, where only the ApiServer itself can update the db for the events changes or any update required like message_log etc.

type WebsocketConnectionData

type WebsocketConnectionData struct {
	UserId         string                        `json:"userId"`
	Token          string                        `json:"token"`
	AccessLevel    model.UserPermissionLevelEnum `json:"access_level"`
	Connection     *websocket.Conn               `json:"connection"`
	OrganizationId string                        `json:"organizationId"`
	Email          string                        `json:"email"`
	Username       string                        `json:"username"`
}

type WebsocketEvent

type WebsocketEvent struct {
	EventName WebsocketEventType `json:"eventName"`
	Data      json.RawMessage    `json:"data"`
	EventId   string             `json:"eventId"`
}

func NewAcknowledgementEvent

func NewAcknowledgementEvent(eventId string, message string) *WebsocketEvent

func NewMessageReceivedWebsocketEvent

func NewMessageReceivedWebsocketEvent(eventId string, message api_types.MessageSchema) *WebsocketEvent

type WebsocketEventDataInterface

type WebsocketEventDataInterface interface {
	GetEventName() string
}

type WebsocketEventType

type WebsocketEventType string
const (
	WebsocketEventTypeMessageAcknowledgement WebsocketEventType = "MessageAcknowledgementEvent"
	WebsocketEventTypeMessage                WebsocketEventType = "MessageEvent"
	WebsocketEventTypeNotificationRead       WebsocketEventType = "NotificationReadEvent"
	WebsocketEventTypeMessageRead            WebsocketEventType = "MessageReadEvent"
	WebsocketEventTypeNewNotification        WebsocketEventType = "NewNotificationEvent"
	WebsocketEventTypeSystemReload           WebsocketEventType = "SystemReloadRequired"
	WebsocketEventTypeConversationAssignment WebsocketEventType = "ConversationAssignmentEvent"
	WebsocketEventTypeConversationClosed     WebsocketEventType = "ConversationClosedEvent"
	WebsocketEventTypeNewConversation        WebsocketEventType = "NewConversationEvent"
	WebsocketEventTypePing                   WebsocketEventType = "PingEvent"
)

Jump to

Keyboard shortcuts

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