// CreateSubscription creates a subscription as configured in the subscriptionProperties, which returns value to the onSubscription callback.
// It returns the status of function call.
CreateSubscription creates a subscription as configured in the subscriptionProperties, which returns value to the onSubscription callback.
It returns the status of function call.
// CreateSubscription creates a subscription as configured in the subscriptionProperties which returns value to the onSubscription callback . // It returns the status of function call .
func (c *Client) CreateSubscription(id string, subscriptionProperties SubscriptionProperties, onSubscription OnSubscription) (*Subscription, Result) {
	data := NewVariant()
	defer DeleteVariant(data)
	subscriptionProperties.Id = id
	jsonBytes, err := subscriptionProperties.BuildJson()
	if err != nil {
		return nil, C.DL_INVALID_VALUE
	}
	propBytes, err := c.converter.JsonToFlatBuffer(jsonBytes)
	if err != nil {
		return nil, C.DL_INVALID_VALUE
	}
	data.SetFlatbuffers(propBytes)
	notifyKey := notifyResponseRegister(func(result Result, notifyItems []NotifyItem) {
		items := make(map[string]Variant)
		for _, notifyItem := range notifyItems {
			info := fbs.GetRootAsNotifyInfo(notifyItem.Info.GetFlatbuffers(), 0)
			items[string(info.Node())] = notifyItem.Data
		}
		onSubscription(result, items)
	})
	r := C.ClientCreateSubscriptionSync(c.this, data.this, notifyKey, nil)
	if r != 0 {
		return nil, Result(r)
	}
	return &Subscription{
		id:        id,
		client:    c.this,
		notifyKey: notifyKey,
		addresses: make(map[string]struct{}),
	}, Result(r)
}
func ( c * Client ) CreateSubscription ( id string , subscriptionProperties SubscriptionProperties , onSubscription OnSubscription ) ( * Subscription , Result ) { data := NewVariant ( ) defer DeleteVariant ( data ) subscriptionProperties . Id = id jsonBytes , err := subscriptionProperties . BuildJson ( ) if err != nil { return nil , C . DL_INVALID_VALUE } propBytes , err := c . converter . JsonToFlatBuffer ( jsonBytes ) if err != nil { return nil , C . DL_INVALID_VALUE } data . SetFlatbuffers ( propBytes ) notifyKey := notifyResponseRegister ( func ( result Result , notifyItems [ ] NotifyItem ) { items := make ( map [ string ] Variant ) for _ , notifyItem := range notifyItems { info := fbs . GetRootAsNotifyInfo ( notifyItem . Info . GetFlatbuffers ( ) , 0 ) items [ string ( info . Node ( ) ) ] = notifyItem . Data } onSubscription ( result , items ) } ) r := C . ClientCreateSubscriptionSync ( c . this , data . this , notifyKey , nil ) if r != 0 { return nil , Result ( r ) } return & Subscription { id : id , client : c . this , notifyKey : notifyKey , addresses : make ( map [ string ] struct { } ) , } , Result ( r ) }
CreateSubscription creates a subscription as configured in the subscriptionProperties, which returns value to the onSubscription callback.
CreateSubscription creates a subscription as configured in the subscriptionProperties which returns value to the onSubscription callback .