sse.io-server-go: github.com/sse-io/sse.io-server-go Index | Files

package sseio

import "github.com/sse-io/sse.io-server-go"

Index

Package Files

client.go eventhandler.go events.go manager.go sseio.go

type ConnectionCloseEvent Uses

type ConnectionCloseEvent struct {
    ClientId string
}

ConnectionCreateEvent will be triggered when a connection is closed.

func (*ConnectionCloseEvent) String Uses

func (c *ConnectionCloseEvent) String() string

type ConnectionCreateEvent Uses

type ConnectionCreateEvent struct {
    ClientId string
    Context  Context
}

ConnectionCreateEvent will be triggered when a connection is created.

func (*ConnectionCreateEvent) String Uses

func (c *ConnectionCreateEvent) String() string

type Context Uses

type Context struct {
    Params map[string]string
    Query  map[string][]string
}

Context which contains Params for route variables and Query for url query parameters

type Event Uses

type Event interface {
    String() string
}

type EventHandler Uses

type EventHandler interface {
    SendMessage(roomId string, message interface{})
    // contains filtered or unexported methods
}

EventHandler interface

func NewEventHandler Uses

func NewEventHandler(event string, manager *manager, opts ...HandlerOptions) (EventHandler, error)

NewEventHandler will return pointer to eventHandler

type HandlerOptions Uses

type HandlerOptions func(e *eventHandler)

HandlerOptions defines option functions to configure the eventHandler.

func SetFetchFunc Uses

func SetFetchFunc(fetch fetch) HandlerOptions

SetFetchFunc will be triggered once a client is connected. And the returned data will be send to the client, and nil data will be ignored.

It's optional.

func SetGetRoomIdFunc Uses

func SetGetRoomIdFunc(getRoomId getRoomId) HandlerOptions

SetGetRoomIdFunc sets the getRoomId function to determine which room the incoming client belongs to.

It's required!

type Options Uses

type Options func(s *sseio)

Options defines option functions to configure the sseio.

func EnableEvent Uses

func EnableEvent() Options

EnableEvent enable the triggered events to be sent the event channel returned by Events method.

func SetPath Uses

func SetPath(path string) Options

SetPath set the url path for sseio

type RoomCreateEvent Uses

type RoomCreateEvent struct {
    RoomId string
}

RoomCreateEvent will be triggered when a room is created by client.

func (*RoomCreateEvent) String Uses

func (e *RoomCreateEvent) String() string

type RoomEmptyEvent Uses

type RoomEmptyEvent struct {
    RoomId string
}

RoomEmptyEvent will be triggered when there is no client in the room. And the room will be deleted.

func (*RoomEmptyEvent) String Uses

func (e *RoomEmptyEvent) String() string

type SSEIO Uses

type SSEIO interface {
    RegisterEventHandler(event string, opts ...HandlerOptions) (EventHandler, error)
    Listen(addr string) error
    Events() chan Event
    Shutdown(context context.Context) error
    ServeHTTP(w http.ResponseWriter, r *http.Request)
}

SSEIO interface. It implements http.Handler interface.

func NewSSEIO Uses

func NewSSEIO(opts ...Options) SSEIO

NewSSEIO will return pointer to sseio that implements the SSEIO

Package sseio imports 10 packages (graph). Updated 2019-12-26. Refresh now. Tools for package owners.