socketigo

package module
v0.0.0-...-6bf63a4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

README

socket.igo

A simple websocket framework for using gorilla websocket inspired by socket.io

Usage

Server Lib
go get -u github.com/nauri-io/socket.igo
Client Lib
npm i sock.igo-client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Id     uuid.UUID
	Events map[string]EventListener
	Server *IgoServer
	// contains filtered or unexported fields
}

func (*Client) Close

func (c *Client) Close() error

func (*Client) Emit

func (c *Client) Emit(eventName string, data interface{}) error

func (*Client) Join

func (c *Client) Join(room *Room)

func (*Client) Leave

func (c *Client) Leave(room *Room)

func (*Client) Off

func (c *Client) Off(eventName string)

func (*Client) On

func (c *Client) On(eventName string, listener EventListener)

func (*Client) Once

func (c *Client) Once(eventName string, listener EventListener)

type EventListener

type EventListener func(client *Client, data map[string]interface{}) interface{}

type IgoServer

type IgoServer struct {
	Clients []*Client
	Rooms   []*Room
	// contains filtered or unexported fields
}

Events: - preconnect: Gets called when the connection is established but the handshake is not yet completed. - connected: Gets called when the connection is established and the handshake is completed. - disconnected: Gets called when the connection is closed.

func CreateIgoServer

func CreateIgoServer(options *IgoServerOptions) *IgoServer

func (*IgoServer) CreateRoom

func (s *IgoServer) CreateRoom(name string) *Room

func (*IgoServer) DeleteRoom

func (s *IgoServer) DeleteRoom(room *Room)

func (*IgoServer) Emit

func (s *IgoServer) Emit(eventName string, data interface{})

func (*IgoServer) EmitExcept

func (s *IgoServer) EmitExcept(client *Client, eventName string, data interface{})

func (*IgoServer) GetRoom

func (s *IgoServer) GetRoom(name string) *Room

func (*IgoServer) Handle

func (s *IgoServer) Handle() IgoServerHandle

func (*IgoServer) OnConnected

func (s *IgoServer) OnConnected(listener func(client *Client))

func (*IgoServer) OnDisconnected

func (s *IgoServer) OnDisconnected(listener func(client *Client))

func (*IgoServer) OnPreConnect

func (s *IgoServer) OnPreConnect(listener func(conn *ws.Conn))

type IgoServerHandle

type IgoServerHandle func(w http.ResponseWriter, r *http.Request)

type IgoServerOptions

type IgoServerOptions struct {
	ReadBufferSize  int
	WriteBufferSize int
	CheckOrigin     func(r *http.Request) bool
}

type Room

type Room struct {
	Id string
	// contains filtered or unexported fields
}

func (*Room) Emit

func (r *Room) Emit(eventName string, data interface{})

func (*Room) EmitExcept

func (r *Room) EmitExcept(client *Client, eventName string, data interface{})

func (*Room) OnClientJoined

func (r *Room) OnClientJoined(listener func(client *Client))

func (*Room) OnClientLeft

func (r *Room) OnClientLeft(listener func(client *Client))

Jump to

Keyboard shortcuts

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