SocketServer

package
v0.0.0-...-43fdc7b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2014 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequireLogin

func RequireLogin(rw http.ResponseWriter, req *http.Request, db *mgo.Database, s sessions.Session, r render.Render)

middleware!

func StartServer

func StartServer()

Types

type Client

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

holds all the info an client needs.

func NewClient

func NewClient(ws *websocket.Conn, server *Server) *Client

func (*Client) Conn

func (c *Client) Conn() *websocket.Conn

getter for client connection

func (*Client) Done

func (c *Client) Done() chan<- bool

return done channel.

func (*Client) Listen

func (c *Client) Listen()

func (*Client) ListenToAll

func (c *Client) ListenToAll()

func (*Client) Write

func (c *Client) Write() chan<- *MessageStruct

get write channel.

type Error

type Error struct {
	ErrorData string
}

type MessageStruct

type MessageStruct struct {
	From    string `json:"from"`
	Message string `json:"body"`
	Type    string `json:"type"`
	Time    int    `json:"time"`
}

type Server

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

func NewServer

func NewServer(path string) *Server

func (*Server) AddClient

func (s *Server) AddClient() chan<- *Client

channel to add a client to the chat.

func (*Server) BroadCast

func (s *Server) BroadCast() chan<- *MessageStruct

channel to broadcast the messages to all clients.

func (*Server) Listen

func (s *Server) Listen()

start server!

func (*Server) Messages

func (s *Server) Messages() []*MessageStruct

holds all the messages from clients.

func (*Server) RemoveClient

func (s *Server) RemoveClient() chan<- *Client

channel to remove a client from the chat.

type User

type User struct {
	UserID   bson.ObjectId `form:"userid"`
	Username string        `form:"username"`
	Password string        `form:"password"`
}

Jump to

Keyboard shortcuts

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