server.go
func (service *ServerService) Register(arg *SubscribeArg, success *bool) error {
	subscribers := service.server.subscribers
	if !service.server.HasClientSubscribed(arg) {
		rpcCallback := service.server.rpcCallback(arg)
		switch arg.SubscribeType {
		case Subscribe:
			service.server.eventBus.Subscribe(arg.Topic, rpcCallback)
		case SubscribeOnce:
			service.server.eventBus.SubscribeOnce(arg.Topic, rpcCallback)
		}
		var topicSubscribers []*SubscribeArg
		if _, ok := subscribers[arg.Topic]; ok {
			topicSubscribers = []*SubscribeArg{arg}
		} else {
			topicSubscribers = subscribers[arg.Topic]
			topicSubscribers = append(topicSubscribers, arg)
		}
		subscribers[arg.Topic] = topicSubscribers
	}
	*success = true
	return nil
}
func (service *ServerService) Register(arg *SubscribeArg, success *bool) error {
	subscribers := service.server.subscribers
	if !service.server.HasClientSubscribed(arg) {
		rpcCallback := service.server.rpcCallback(arg)
		switch arg.SubscribeType {
		case Subscribe:
			service.server.eventBus.Subscribe(arg.Topic, rpcCallback)
		case SubscribeOnce:
			service.server.eventBus.SubscribeOnce(arg.Topic, rpcCallback)
		}
		var topicSubscribers []*SubscribeArg
		if _, ok := subscribers[arg.Topic]; ok {
			topicSubscribers = []*SubscribeArg{arg}
		} else {
			topicSubscribers = subscribers[arg.Topic]
			topicSubscribers = append(topicSubscribers, arg)
		}
		subscribers[arg.Topic] = topicSubscribers
	}
	*success = true
	return nil
}
func ( service * ServerService ) Register ( arg * SubscribeArg , success * bool ) error { subscribers := service . server . subscribers if ! service . server . HasClientSubscribed ( arg ) { rpcCallback := service . server . rpcCallback ( arg ) switch arg . SubscribeType { case Subscribe : service . server . eventBus . Subscribe ( arg . Topic , rpcCallback ) case SubscribeOnce : service . server . eventBus . SubscribeOnce ( arg . Topic , rpcCallback ) } var topicSubscribers [ ] * SubscribeArg if _ , ok := subscribers [ arg . Topic ] ; ok { topicSubscribers = [ ] * SubscribeArg { arg } } else { topicSubscribers = subscribers [ arg . Topic ] topicSubscribers = append ( topicSubscribers , arg ) } subscribers [ arg . Topic ] = topicSubscribers } * success = true return nil }
// Register - Registers a remote handler to this event bus
// for a remote subscribe - a given client address only needs to subscribe once
// event will be republished in local event bus
Register - Registers a remote handler to this event bus for a remote subscribe - a given client address only needs to subscribe once event will be republished in local event bus