ws

package
v0.0.0-...-0cb0207 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Provide(func(game *game.Game) *Server {

	return NewServer(game, "8000")
})

Module ... fx module export

Functions

This section is empty.

Types

type DisplayRoom

type DisplayRoom struct {
	Type string     `json:"type"`
	Room *game.Room `json:"room"`
}

DisplayRoom ...

func NewDisplayRoom

func NewDisplayRoom(room *game.Room) *DisplayRoom

NewDisplayRoom ... creates new display room message

type Message

type Message struct {
	Type     string `json:"type"`
	Username string `json:"username"`
	Message  string `json:"message"`
}

Message ... Define our message object

func NewWebSocketMessage

func NewWebSocketMessage(user string, message string) *Message

NewWebSocketMessage ... creates a new Websocket message

type MessageHandler

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

MessageHandler ... tcp ..

func NewMessageHandler

func NewMessageHandler(server *Server) *MessageHandler

NewMessageHandler ... creates a new message handler

func (*MessageHandler) OnMessage

func (messageHandler *MessageHandler) OnMessage(message interface{})

OnMessage .. broadcast receiver

type Server

type Server struct {
	Clients   map[*websocket.Conn]bool
	Users     map[string]*websocket.Conn
	Broadcast chan Message

	MessageHandler *MessageHandler
	// contains filtered or unexported fields
}

Server ... Define our message object

func NewServer

func NewServer(game *game.Game, port string) *Server

NewServer ... creates a new websocketserver instance

func (*Server) OnSystemMessage

func (server *Server) OnSystemMessage(message *game.Message)

OnSystemMessage .. broadcast receiver

func (*Server) Start

func (server *Server) Start()

Start ... start websocketserver

func (*Server) Stop

func (server *Server) Stop()

Stop ... start websocketserver

Jump to

Keyboard shortcuts

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