コード例 #1
0
func (c *commandStrategy) msgBroadcast() error {
	c.app.RWMutex.RLock()
	defer c.app.RWMutex.RUnlock()

	var id string
	content := c.body["content"]

	logging.Debug("Sending message broadcast from %s", c.app.Manifest.InstanceId)

	if id_, ok := getString(c.body, "id"); ok {
		id = id_
	} else {
		return errors.New("No id found")
	}

	msg_archive.RecordMsg(c.app, id)
	toSend := make(jsonData)
	toSend["fromInstanceId"] = c.app.Manifest.InstanceId
	toSend["id"] = id
	toSend["content"] = content
	for _, cpb := range c.app.Manifest.Capabilities {
		for _, dep := range registry.GetDependents(cpb) {
			dep.Send("MSG_BROADCAST", toSend)
		}
	}
	return nil
}
コード例 #2
0
func sendDependencyNotice(a *app.App) {
	// notify everyone who depends on us
	for _, cpb := range a.Manifest.Capabilities {
		for _, dependent := range registry.GetDependents(cpb) {
			body := make(jsonData)
			inner := make(jsonData)
			inner[a.Manifest.InstanceId] = a.StatusString()
			body[cpb.Name] = inner
			dependent.Send("APP_DEPENDENCY", body)
		}
	}
}