• Stars
    star
    167
  • Rank 221,845 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight Go WebSocket-Framework

golem v0.4.4

A lightweight extendable Go WebSocket-framework with client library.

Status

The project can be considered dead. There has been no development in recent years. It is still available on github for research and archiving purposes.

License

Golem is available under the Apache License, Version 2.0

Installation

go get github.com/trevex/golem

Client

A client is also available and heavily used in the examples. More information on how the client is used can be found in the client repository.

Simple Example

Server:

type Hello struct {
	From string `json:"from"`
}
type Answer struct {
	Msg string `json:"msg"`
}
func hello(conn *golem.Connection, data *Hello) {
	conn.Emit("answer", &Answer{"Thanks, "+ data.From + "!"})
}
func main() {
	myrouter := golem.NewRouter()
	myrouter.On("hello", hello)
	http.HandleFunc("/ws", myrouter.Handler())
	http.ListenAndServe(":8080", nil)
}

Client:

var conn = new golem.Connection("ws://127.0.0.1:8080/ws", true);
conn.on("answer", function(data) {
    console.log("Answer: "+data.msg);
});
conn.on("open", function() {
    conn.emit("hello", { from: "Client" });
});

Output in client console would be Thanks, Client!.

Documentation

The documentation is provided via godoc.

Wiki & Tutorials

More informations and insights can be found on the wiki page along with a tutorial series to learn how to use golem:

More Examples

Several examples are available in the example repository. To use them simply checkout the repository and make sure you installed (go get) golem before. A more detailed guide on how to use them is located in their repository.

History

  • v0.1.0
    • Basic API layout and documentation
  • v0.2.0
    • Evented communication system and routing
    • Basic room implementation (lobbies renamed to rooms for clarity)
  • v0.3.0
    • Protocol extensions through Parsers
    • Room manager for collections of rooms
  • v0.4.0
    • Protocol interchangable
    • Several bugfixes
    • Client up-to-date
  • v0.4.2
    • Connection type can be extended
    • Close added to connection
  • v0.4.3
    • RoomManager emiting create- and remove-events (remove if room has insufficient users)
  • v0.4.4
    • RoomManager manages set of connection dependent options, see example_chat_options.go
    • Router provides OnConnect callback

Special thanks

  • Gary Burd (for the great WebSocket protocol implementation and insights through his examples)
  • Andrew Gallant (for help on golang-nuts mailing list)
  • Kortschak (for help on golang-nuts mailing list)

Contributors

TODO

  • Verbose and configurable logging
  • Testing