# README
= Tunnel.go
Is a dead simple messaging system written in Go. It aims to facilitate the dialogue and messages exchange between services.
It's based on top of TCP with a custom protocol.
See https://github.com/codingLayce/tunnel-server
for a Tunnel server command tool.
== Go Client
Client SDK in Golang to communicate with a Tunnel server.
=== Connect to a Tunnel server
[source,Go]
import "github.com/codingLayce/tunnel.go"
func main() {
client, err := tunnel.Connect("tunnel.server.addr:19917")
if err != nil {
panic(err)
}
defer client.Stop() // Don't forget for graceful shutdown
}
=== Create a Brodcast Tunnel
After a successful call to CreateBTunnel
a broadcast Tunnel is created server-side.
[source,Go]
import "github.com/codingLayce/tunnel.go"
func main() {
// ... client setup ...
err := client.CreateBTunnel("MyTunnel")
if err != nil {
panic(err)
}
}
=== Broadcast a message
After a successful call to PublishMessage
the given message will be broadcast to all listeners.
[source,Go]
import "github.com/codingLayce/tunnel.go"
func main() {
// ... client setup ...
err := client.PublishMessage("MyTunnel", "Lovely message")
if err != nil {
panic(err)
}
}
=== Listen to Tunnel
After a successful call to ListenTunnel
when a message arrives to the client, it will invoke the given callback.
[source,Go]
import "github.com/codingLayce/tunnel.go"
func main() {
// ... client setup ...
err := client.ListenTunnel("MyTunnel", func(msg string){
fmt.Printf("Message received: %s\n", msg)
})
if err != nil {
panic(err)
}
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
Connect creates a new Client and connects to a Tunnel server.
# Interfaces
No description provided by the author