Пример #1
0
func (m Engine) SubscribeClient(request protocol.Message, client *protocol.Client) {
	response := m.responseFromRequest(request)
	response["successful"] = true

	subscription := request["subscription"]
	response["subscription"] = subscription

	var subs []string
	switch subscription.(type) {
	case []string:
		subs = subscription.([]string)
	case string:
		subs = []string{subscription.(string)}
	}

	for _, s := range subs {
		// Do not register clients subscribing to a service channel
		// They will be answered directly instead of through the normal subscription system
		if !protocol.NewChannel(s).IsService() {
			m.AddSubscription(client.Id(), []string{s})
		}
	}

	client.Queue(response)
}
Пример #2
0
func (cr ClientRegister) AddClient(client *protocol.Client) {
	cr.clients.Put(client.Id(), client)
}