All Projects β†’ antoniodipinto β†’ ikisocket

antoniodipinto / ikisocket

Licence: MIT license
🧬 WebSocket wrapper with event management for Fiber https://github.com/gofiber/fiber. Based on Fiber WebSocket and inspired by Socket.io

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to ikisocket

Steam-Apps-Management-API
A basic Steam Application Management API and Valve Data Format (VDF) reader/writer.
Stars: ✭ 24 (-73.91%)
Mutual labels:  events, listener
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-25%)
Mutual labels:  events, socket-io
Laravel Event Broadcast
Laravel event broadcasting with Node.js, Redis & Socket.io
Stars: ✭ 5 (-94.57%)
Mutual labels:  events, socket-io
event-worker
A simpler way of dealing with Web Workers
Stars: ✭ 18 (-80.43%)
Mutual labels:  events, listener
jetemit
jetemit is an event manager for React, React Native, Vue, Angular, and all javascript project
Stars: ✭ 44 (-52.17%)
Mutual labels:  events, listener
spa-bus
πŸ”₯Tools for multilevel components to pass values in any SPA
Stars: ✭ 15 (-83.7%)
Mutual labels:  events, listener
micro-typed-events
The smallest, most convenient typesafe TS event emitter you'll ever need
Stars: ✭ 39 (-57.61%)
Mutual labels:  events, listener
tardis
Event sourcing toolkit
Stars: ✭ 35 (-61.96%)
Mutual labels:  events
socketio-jwt-auth
Socket.io authentication middleware using Json Web Token
Stars: ✭ 87 (-5.43%)
Mutual labels:  socket-io
quickmeet
A video chat/meeting webapp using WebRTC and WebSockets. Basically a Google Meet clone + a collaborative Whiteboard.
Stars: ✭ 75 (-18.48%)
Mutual labels:  socket-io
go-graphql-subscription-example
☝️ go-graphql subscription over Kafka/Redis/NSQ example
Stars: ✭ 34 (-63.04%)
Mutual labels:  events
EventEmitter
Simple EventEmitter with multiple listeners
Stars: ✭ 19 (-79.35%)
Mutual labels:  events
trainmanjs
TrainmanJS - Cross-Origin Communication Library
Stars: ✭ 16 (-82.61%)
Mutual labels:  events
spiced academy--p2p chat
A fun and easy messaging app that allows private conversations through P2P
Stars: ✭ 17 (-81.52%)
Mutual labels:  socket-io
vue-music-player
🎡 basic music player, keeps your favorite musics
Stars: ✭ 77 (-16.3%)
Mutual labels:  listener
realtime-geolocation
Geolocation tracking app with Node.js, Socket.io, & AngularJS
Stars: ✭ 29 (-68.48%)
Mutual labels:  socket-io
just-drop-it
Simply and instantly beam a file between two browsers
Stars: ✭ 22 (-76.09%)
Mutual labels:  socket-io
socket.io-react
A High-Order component to connect React and Socket.io easily
Stars: ✭ 67 (-27.17%)
Mutual labels:  socket-io
unite
Microsoft Engage 2021 - Video Conferencing Application
Stars: ✭ 143 (+55.43%)
Mutual labels:  socket-io
Project12-C-Slack-Web
πŸ”₯πŸ”₯πŸ”₯πŸš€βš‘ [12-CνŒ€] κ²λ‚˜ λΉ λ₯Έ μŠ¬λž™ ν”„λ‘œμ νŠΈ βš‘πŸš€πŸ”₯πŸ”₯πŸ”₯
Stars: ✭ 22 (-76.09%)
Mutual labels:  socket-io

WebSocket wrapper for Fiber v2 with events support

Go Report Card GoDoc GitHub license

Based on Fiber Websocket and inspired by Socket.io

Upgrade to Fiber v2 details here

Any bug?

Create ad issue following this template

Feature request?

Create ad issue following this template

βš™οΈ Installation

go get -u github.com/antoniodipinto/ikisocket

πŸ“– ️ Documentation

// Initialize new ikisocket in the callback this will
// execute a callback that expects kws *Websocket Object
New(callback func(kws *Websocket)) func(*fiber.Ctx) error

// Add listener callback for an event into the listeners list
On(event string, callback func(payload *EventPayload))

ikisocket public/global functions (many thanks to Daniel Morawetz)

// Emit the message to a specific socket uuids list
// Ignores all errors
EmitToList(uuids []string, message []byte)

// Emit to a specific socket connection
EmitTo(uuid string, message []byte) error

// Broadcast to all the active connections
// except avoid broadcasting the message to itself
Broadcast(message []byte)

// Fire custom event on all connections
Fire(event string, data []byte) 

Supported events:

// Supported event list
const (
	// Fired when a Text/Binary message is received
	EventMessage = "message"
	// More details here:
	// @url https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#Pings_and_Pongs_The_Heartbeat_of_WebSockets
	EventPing = "ping"
	EventPong = "pong"
	// Fired on disconnection
	// The error provided in disconnection event
	// is defined in RFC 6455, section 11.7.
	// @url https://github.com/gofiber/websocket/blob/cd4720c435de415b864d975a9ca23a47eaf081ef/websocket.go#L192
	EventDisconnect = "disconnect"
	// Fired on first connection
	EventConnect = "connect"
	// Fired when the connection is actively closed from the server
	EventClose = "close"
	// Fired when some error appears useful also for debugging websockets
	EventError = "error"
)

Event Payload object

// Event Payload is the object that
// stores all the information about the event and
// the connection
type EventPayload struct {
	// The connection object
	Kws *Websocket
	// The name of the event
	Name string
	// Unique connection UUID
	SocketUUID string
	// Optional websocket attributes
	SocketAttributes map[string]string
	// Optional error when are fired events like
	// - Disconnect
	// - Error
	Error error
	// Data is used on Message and on Error event
	Data []byte
}

Socket instance functions

// Set a specific attribute for the specific socket connection
func (kws *Websocket) SetAttribute(key string, attribute string)

// Get socket connection UUID
func (kws *Websocket) GetUUID() string

// Set socket connection UUID
func (kws *Websocket) SetUUID(uuid string)

// Set socket connection UUID
func (kws *Websocket) SetUUID(uuid string)

// Get a specific attribute from the socket attributes
func (kws *Websocket) GetAttribute(key string) string

// Emit the message to a specific socket uuids list
func (kws *Websocket) EmitToList(uuids []string, message []byte) 

// Emit to a specific socket connection
func (kws *Websocket) EmitTo(uuid string, message []byte) error

// Broadcast to all the active connections
// except avoid broadcasting the message to itself
func (kws *Websocket) Broadcast(message []byte, except bool)

// Fire custom event
func (kws *Websocket) Fire(event string, data []byte)

// Emit/Write the message into the given connection
func (kws *Websocket) Emit(message []byte)

// Actively close the connection from the server
func (kws *Websocket) Close() 

⚑️ Examples

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].