func (bitverseObserver *BitverseObserver) OnConnected(node *bitverse.EdgeNode, remoteNode *bitverse.RemoteNode) { fmt.Println("-> now connected to super node " + remoteNode.Id()) remoteNode.SendChildrenRequest() msgService := node.GetMsgService(serviceId) msgService.SendAndGetReply("6a133a1b41f987210559ceb4ed9b1dbf58aec876", "hello", 10, func(err error, reply interface{}) { if err == nil { fmt.Println("that was a surprise " + reply.(string)) } else { // we will most likely timeout unless node 6a133a1b41f987210559ceb4ed9b1dbf58aec876 is online fmt.Println("failed to send message to node with id 6a133a1b41f987210559ceb4ed9b1dbf58aec876") } }) }
func (bitverseObserver *BitverseObserver) OnSiblingJoined(node *bitverse.EdgeNode, id string) { fmt.Println("-> sibling " + id + " joined") msgService := node.GetMsgService(serviceId) msgService.Send(id, "hello") fmt.Println("sending: hello") fmt.Println("sending: who are you?") msgService.SendAndGetReply(id, "who are you?", 10, func(err error, reply interface{}) { if err == nil { fmt.Println("got a reply (who are you?): " + reply.(string)) } else { fmt.Println("failed to get a reply for (who are you?)") } }) }