コード例 #1
0
        //---private methods---
        private HMessage InnerBuildResult(string actor, string @ref, ResultStatus? status, JToken result, HMessageOptions mOptions)
        {
            if (actor == null || actor.Length <= 0)
                throw new MissingAttrException("actor");
            if (@ref == null || @ref.Length <= 0)
                throw new MissingAttrException("ref");
            if (status == null)
                throw new MissingAttrException("status");

            HResult hResult = new HResult();
            hResult.SetResult(result);
            hResult.SetStatus(status);
            if (mOptions == null)
                mOptions = new HMessageOptions();
            mOptions.Ref = @ref;

            return BuildMessage(actor, "hResult", hResult, mOptions);
        }
コード例 #2
0
        private HMessage InnerBuildMessage(string actor, string type, JToken payload, HMessageOptions mOptions)
        {
            if (actor == null || actor.Length <= 0)
                throw new MissingAttrException("actor");

            HMessage message = new HMessage();
            message.SetActor(actor);
            message.SetType(type);
            if (mOptions != null)
            {
                message.SetRef(mOptions.Ref);
                message.SetConvid(mOptions.Convid);
                message.SetPriority(mOptions.Priority);
                message.SetAuthor(mOptions.Author);
                message.SetHeaders(mOptions.Headers);
                message.SetLocation(mOptions.Location);
                message.SetPublished(mOptions.Published);
                message.SetPersistent(mOptions.Persistent);
                message.SetTimeout(mOptions.Timeout);
                if (mOptions.RelevanceOffset != null)
                {
                    Debug.WriteLine("----   " + mOptions.RelevanceOffset);
                    message.SetRelevance((DateTime.UtcNow).AddMilliseconds(mOptions.RelevanceOffset.Value));
                    Debug.WriteLine("++++   " + message.GetRelevance());
                }
                else
                    message.SetRelevance(mOptions.Relevance);
            }
            if (transportOptions != null && transportOptions.Login != null)
                message.SetPublisher(transportOptions.FullUrn);
            else
                message.SetPublisher(null);
            message.SetPayload(payload);
            return message;
        }
コード例 #3
0
 public HMessage BuildResult(string actor, string @ref, ResultStatus status, double result, HMessageOptions mOptions)
 {
     return InnerBuildResult(actor, @ref, status, result, mOptions);
 }
コード例 #4
0
 public HMessage BuildMessage(string actor, string type, HResult payload, HMessageOptions mOptions)
 {
     return InnerBuildMessage(actor, type, payload, mOptions);
 }
コード例 #5
0
        /// <summary>
        /// since v0.5
        /// The client MUST be connected to access to this service.
        /// Allow a hubapp client to create a hMessage with a hCommand payload.
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="cmd"></param>
        /// <param name="params"></param>
        /// <param name="filter"></param>
        /// <param name="mOptions"></param>
        /// <returns></returns>
        public HMessage BuildCommand(string actor, string cmd, JToken @params, HCondition filter, HMessageOptions mOptions)
        {
            if (actor == null || actor.Length <= 0)
                throw new MissingAttrException("actor");
            if (cmd == null || cmd.Length <= 0)
                throw new MissingAttrException("cmd");

            HCommand hcommand = new HCommand(cmd, @params, filter);

            HMessage hmessage = BuildMessage(actor, "hCommand", hcommand, mOptions);
            return hmessage;
        }
コード例 #6
0
        private void sendBt_Click(object sender, RoutedEventArgs e)
        {
            HMessageOptions mOptions = new HMessageOptions();

            if (persistentCb.IsChecked.Value)
                mOptions.Persistent = true;
            else
                mOptions.Persistent = false;

            if (!string.IsNullOrEmpty(timeoutTbx.Text))
                mOptions.Timeout = int.Parse(timeoutTbx.Text);

            if (!string.IsNullOrEmpty(relevantTbx.Text))
                mOptions.RelevanceOffset = int.Parse(relevantTbx.Text);

            HMessage hMsg = client.BuildMessage(actorTbx.Text, "string", msgTbx.Text, mOptions);
            client.Send(hMsg, null);
            
            Debug.WriteLine(">>>Send Message<<<\n" + hMsg.ToString() + "\n");
            Debug.WriteLine(">>>BareJid<<<\n" + client.BareJid + "\n");

        }