(callerId string, topic string, protocols []interface{})
| 292 | } |
| 293 | |
| 294 | func (node *defaultNode) requestTopic(callerId string, topic string, protocols []interface{}) (interface{}, error) { |
| 295 | node.logger.Debugf("Slave API requestTopic(%s, %s, ...) called.", callerId, topic) |
| 296 | var code int32 |
| 297 | var message string |
| 298 | var value interface{} |
| 299 | if pub, ok := node.publishers[topic]; !ok { |
| 300 | node.logger.Debug("requestTopic() called with not publishing topic.") |
| 301 | code = 0 |
| 302 | message = "No such topic" |
| 303 | value = nil |
| 304 | } else { |
| 305 | selectedProtocol := make([]interface{}, 0) |
| 306 | for _, v := range protocols { |
| 307 | protocolParams := v.([]interface{}) |
| 308 | protocolName := protocolParams[0].(string) |
| 309 | if protocolName == "TCPROS" { |
| 310 | node.logger.Debug("TCPROS requested") |
| 311 | selectedProtocol = append(selectedProtocol, "TCPROS") |
| 312 | host, portStr := pub.hostAndPort() |
| 313 | p, err := strconv.ParseInt(portStr, 10, 32) |
| 314 | if err != nil { |
| 315 | return nil, err |
| 316 | } |
| 317 | port := int(p) |
| 318 | selectedProtocol = append(selectedProtocol, host) |
| 319 | selectedProtocol = append(selectedProtocol, port) |
| 320 | break |
| 321 | } |
| 322 | } |
| 323 | node.logger.Debug(selectedProtocol) |
| 324 | code = 1 |
| 325 | message = "Success" |
| 326 | value = selectedProtocol |
| 327 | } |
| 328 | return buildRosApiResult(code, message, value), nil |
| 329 | } |
| 330 | |
| 331 | func (node *defaultNode) NewPublisher(topic string, msgType MessageType) Publisher { |
| 332 | name := node.nameResolver.remap(topic) |
no test coverage detected