All Projects → madari → Go Socket.io

madari / Go Socket.io

Licence: mit
A Socket.IO backend implementation written in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Socket.io

Node Decorators
node-decorators
Stars: ✭ 230 (-43.77%)
Mutual labels:  socketio, socket-io
pdfdraw
Nextcloud app to annotate PDF documents
Stars: ✭ 32 (-92.18%)
Mutual labels:  socket-io, socketio
realtime-geolocation
Geolocation tracking app with Node.js, Socket.io, & AngularJS
Stars: ✭ 29 (-92.91%)
Mutual labels:  socket-io, socketio
Phpsocket.io
A server side alternative implementation of socket.io in PHP based on workerman.
Stars: ✭ 2,026 (+395.35%)
Mutual labels:  socketio, socket-io
django-channels-with-socket.io
django channels with socket.io
Stars: ✭ 23 (-94.38%)
Mutual labels:  socket-io, socketio
Socketio Wildcard
socket.io v2.x with a wildcard event
Stars: ✭ 185 (-54.77%)
Mutual labels:  socketio, socket-io
socket.io-client-core
High-Performance Socket.IO client in C#
Stars: ✭ 70 (-82.89%)
Mutual labels:  socket-io, socketio
SocketIOSharp
C# implementation of Socket.IO protocol revision 4 client and server.
Stars: ✭ 101 (-75.31%)
Mutual labels:  socket-io, socketio
VPSocketIO
socket.io client objective-c
Stars: ✭ 18 (-95.6%)
Mutual labels:  socket-io, socketio
gobang
五子棋小游戏canvas socket.io
Stars: ✭ 38 (-90.71%)
Mutual labels:  socket-io, socketio
Aaronvandenberg.nl
⚛️ Web Developers portfolio build with Gatsby.js & React.js
Stars: ✭ 98 (-76.04%)
Mutual labels:  socketio, socket-io
bubbly
Full stack chat application created w/ Next.js, Socket.IO, Express, React and TypeScript
Stars: ✭ 24 (-94.13%)
Mutual labels:  socket-io, socketio
Socket.io Python Emitter
Python implementation of socket.io-emitter
Stars: ✭ 67 (-83.62%)
Mutual labels:  socketio, socket-io
Python Socketio
Python Socket.IO server and client
Stars: ✭ 2,655 (+549.14%)
Mutual labels:  socketio, socket-io
Bizsocket
异步socket,对一些业务场景做了支持
Stars: ✭ 469 (+14.67%)
Mutual labels:  socketio, socket-io
titanium-socketio
Use the native Socket.io SDK's with Axway Titanium.
Stars: ✭ 25 (-93.89%)
Mutual labels:  socket-io, socketio
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-83.13%)
Mutual labels:  socket-io, socketio
boltly
Boltly: The complete Socket.io test client!
Stars: ✭ 16 (-96.09%)
Mutual labels:  socket-io, socketio
Socket.io Tester
Deprecated: An electron app that lets you connect to a socket.io server and subscribe to a certain topic and/or lets you send socket messages to the server
Stars: ✭ 297 (-27.38%)
Mutual labels:  socket-io
Vue Chess
Multiplayer online chess game use Vue , Nodejs, Webpack, Em6, Socket.io, Mongodb, Express
Stars: ✭ 350 (-14.43%)
Mutual labels:  socket-io

go-socket.io

The socketio package is a simple abstraction layer for different web browser- supported transport mechanisms. It is fully compatible with the Socket.IO client (version 0.6) JavaScript-library by LearnBoost Labs. By writing custom codecs the socketio could be perhaps used with other clients, too.

It provides an easy way for developers to rapidly prototype with the most popular browser transport mechanism today:

Compatibility with Socket.IO 0.7->

Go-socket.io is currently compatible with Socket.IO 0.6 clients only.

Demo

The Paper Experiment

Crash course

The socketio package works hand-in-hand with the standard http package (by plugging itself into http.ServeMux) and hence it doesn't need a full network port for itself. It has an callback-style event handling API. The callbacks are:

  • SocketIO.OnConnect
  • SocketIO.OnDisconnect
  • SocketIO.OnMessage

Other utility-methods include:

  • SocketIO.ServeMux
  • SocketIO.Broadcast
  • SocketIO.BroadcastExcept
  • SocketIO.GetConn

Each new connection will be automatically assigned an session id and using those the clients can reconnect without losing messages: the server persists clients' pending messages (until some configurable point) if they can't be immediately delivered. All writes are by design asynchronous and can be made through Conn.Send. The server also abstracts handshaking and various keep-alive mechanisms.

Finally, the actual format on the wire is described by a separate Codec. The default bundled codecs, SIOCodec and SIOStreamingCodec are fully compatible with the LearnBoost's Socket.IO client (master and development branches).

Example: A simple chat server

package main

import (
	"http"
	"log"
	"socketio"
)

func main() {
	sio := socketio.NewSocketIO(nil)

	sio.OnConnect(func(c *socketio.Conn) {
		sio.Broadcast(struct{ announcement string }{"connected: " + c.String()})
	})

	sio.OnDisconnect(func(c *socketio.Conn) {
		sio.BroadcastExcept(c,
			struct{ announcement string }{"disconnected: " + c.String()})
	})

	sio.OnMessage(func(c *socketio.Conn, msg socketio.Message) {
		sio.BroadcastExcept(c,
			struct{ message []string }{[]string{c.String(), msg.Data()}})
	})

	mux := sio.ServeMux()
	mux.Handle("/", http.FileServer("www/", "/"))

	if err := http.ListenAndServe(":8080", mux); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
}

tl;dr

You can get the code and run the bundled example by following these steps:

$ git clone git://github.com/madari/go-socket.io.git
$ cd go-socket.io
$ git submodule update --init --recursive
$ make install
$ cd example
$ make
$ ./example

License

(The MIT License)

Copyright (c) 2011 Jukka-Pekka Kekkonen <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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].