ChatterBox.Client.Universal.Background.Helpers.AppServiceChannelHelper.InvokeChannel C# (CSharp) Method

InvokeChannel() public static method

Sends a new message using the AppServiceConnection, containing the contract name, the method name and the serialized argument
public static InvokeChannel ( this connection, Type contractType, object argument, string method ) : ValueSet
connection this
contractType System.Type
argument object
method string
return ValueSet
        public static ValueSet InvokeChannel(this AppServiceConnection connection, Type contractType, object argument,
            string method)
        {

            //Create a new instance of the channel writer and format the message (format: <Method> <Argument - can be null and is serialized as JSON>)
            var channelWriteHelper = new ChannelWriteHelper(contractType);
            var message = channelWriteHelper.FormatOutput(argument, method);

            //Send the message with the key being the contract name and the value being the serialized message
            var sendMessageTask = connection.SendMessageAsync(new ValueSet {{contractType.Name, message}}).AsTask();
            sendMessageTask.Wait();

            //If the message send resulted in a failure, return null, otherwise return the ValueSet result
            return sendMessageTask.Result.Status != AppServiceResponseStatus.Success
                ? null
                : sendMessageTask.Result.Message;
        }

Same methods

AppServiceChannelHelper::InvokeChannel ( this connection, Type contractType, object argument, string method, Type responseType ) : object