Before running the examples, move to the installation directory of Speer:
cd $GOPATH/src/github.com/danalex97/Speer
We provide the following examples:
go run speer.go -config=examples/config/sink.json
go run speer.go -config=examples/config/broadcast.json
go run speer.go -config=examples/config/data_link.json
For a more complex example, check this repository.
Getting the bootstrap node id:
id := util.Join()
Sending a control message:
util.Transport().ControlSend(id, "message")
Receiving a control message:
msg := <-util.Transport().ControlRecv()
Sending data via a link:
// Creating the link
link := util.Transport().Connect(id)
// Sending the data
link.Upload(Data{
Id : "someUniqueId", // Some ID associated with the message.
// The ID can be used for keeping the actual data or metadata.
Size : 1000, // Total data size in bits.
})
Getting data from a link:
data := <-link.Download()
Setting up a callback:
util.Callback(100, func() {
// [...]
})
Setting up a periodic routine:
util.Routine(100, func() {
// [...]
})