Esempio n. 1
0
        /// <summary>
        /// Subscribes to the channel on the destination path.
        /// </summary>
        /// <param name="destinationPath">The channel.</param>
        async Task SendSubscribeStompMsgAsync(string destinationPath, Address destinationAddress = null)
        {
            StompMessage subscribe = new StompMessage(StompMessage.ClientCommands.SUBSCRIBE);

            subscribe.SetSubscriptionId(SubscriptionCounter++);
            subscribe.SetDestination(destinationPath, destinationAddress);
            await SendAsync(subscribe);  // The LoopReadStompMsgsAsync will process the answer from the server

            Debug.WriteLine("Subscription requested on path " + subscribe.GetDestination());
        }
Esempio n. 2
0
        /// <summary>
        /// Subscribes to the channel for Definitions of Mosaics owned by the given Account. The Eventhandler will be invoked when a message is received on the channel.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="mosaicDefinitionEventHandler"></param>
        /// <returns></returns>
        public async Task SubscribeToOwnedMosaicDefinitionsAsync(string account, Action <Address, MosaicInfo> mosaicDefinitionEventHandler)
        {
            Address destinationAddress = new Address(account);

            this.OnMosaicDefinitionEventHandler = mosaicDefinitionEventHandler;
            await SendSubscribeStompMsgAsync(ChannelPaths.OWNEDMOSAICDEFINITION, destinationAddress);

            // Send an explicit message to request an immediate answer on the channel
            StompMessage send = new StompMessage(StompMessage.ClientCommands.SEND, "{'account':'" + destinationAddress.Plain + "'}");

            send.SetDestination(ApiPaths.OWNEDMOSAICDEFINITIONS);
            await SendAsync(send);  // The LoopReadStompMsgsAsync will process the answer from the server
        }
Esempio n. 3
0
        /// <summary>
        /// Subscribes to the channel for Mosaics owned by the given Account. The Eventhandler will be invoked when a message is received on the channel.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="mosaicEventHandler"></param>
        public async Task SubscribeToOwnedMosaicsAsync(string account, Action <Address, MosaicAmount> mosaicEventHandler)
        {
            Address destinationAddress = new Address(account);

            this.OnMosaicEventHandler = mosaicEventHandler;   // The callback will be invoked for each msg received per Mosaic owned
            await SendSubscribeStompMsgAsync(ChannelPaths.OWNEDMOSAICS, destinationAddress);

            // Send an explicit message to request an immediate answer on the channel
            StompMessage send = new StompMessage(StompMessage.ClientCommands.SEND, "{'account':'" + destinationAddress.Plain + "'}");

            send.SetDestination(ApiPaths.OWNEDMOSAICS);
            await SendAsync(send);  // The LoopReadStompMsgsAsync will process the answer from the server
        }
Esempio n. 4
0
        /// <summary>
        /// Subscribes to the channel for an Account. The Eventhandler will be invoked when a message is received on the channel.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="accountEventHandler"></param>
        public async Task SubscribeToAccountAsync(string account, Action <AccountInfo> accountEventHandler)
        {
            Address destinationAddress = new Address(account);

            this.OnAccountEventHandler = accountEventHandler;
            await SendSubscribeStompMsgAsync(ChannelPaths.ACCOUNT, destinationAddress);

            // Send an explicit message to request an immediate answer on the channel
            StompMessage send = new StompMessage(StompMessage.ClientCommands.SEND, "{'account':'" + destinationAddress.Plain + "'}");

            send.SetDestination(ApiPaths.ACCOUNT);
            await SendAsync(send);  // The LoopReadStompMsgsAsync will process the answer from the server
        }