/// <summary>
        /// 发送聊天消息
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="message"></param>
        public void SendMessage(string interactionID, string userID, string message)
        {
            if (!string.IsNullOrEmpty(message))
            {
                message = Microsoft.JScript.GlobalObject.decodeURIComponent(message);
            }

            if (string.IsNullOrEmpty(interactionID))
            {
                if (this.Room != null)
                {
                    interactionID = this.Room.RoomID;
                }
                else
                {
                    interactionID = this.Room.SessionID;
                }
            }
            try
            {
                ChatLog.GetInstance().FormatMessage("发送消息:SessionID:{0},Content:{1}", interactionID, message);
                MessageText    text    = MessageText.Create(message);
                RequestMessage request = RequestMessage.Create(interactionID, Visibility.All, text);
                ChatLog.GetInstance().FormatMessage("发送消息:SessionID:{0}.begin", interactionID);
                this.SendMessage(userID, request);
            }
            catch (Exception ex)
            {
                ChatLog.GetInstance().LogException(ex);
            }
            ChatLog.GetInstance().FormatMessage("发送消息:SessionID:{0}.end", interactionID);
        }
Beispiel #2
0
        public object Call(string actionName, JObject parms, JObject opts)
        {
            ServiceEntry entry = _locator.GetServiceEntry(actionName)[0];

            if (entry == null)
            {
                throw new InvalidOperationException($"service {actionName} not found");
            }

            string newGuid = Guid.NewGuid().ToString();

            Semaphores[newGuid] = new Semaphore(0, 1);
            RequestMessage reqMessage = RequestMessage.Create(actionName, parms, newGuid);
            string         obj        = reqMessage.ToString();

            _transporter.Publish($"MOL.REQB.{entry.ServiceName}", reqMessage);
            Semaphores[newGuid].WaitOne();
            return(Values[newGuid]);
        }
        public void Execute(string interactionId, string messageText)
        {
            try
            {
                RequestMessage reqMessage = RequestMessage.Create(
                    interactionId,
                    Genesyslab.Platform.WebMedia.Protocols.BasicChat.Visibility.All,
                    MessageText.Create(messageText));

                BaseAction action = new ChatMessageAction(Protocol);

                action.Request = reqMessage;

                base.CloneSubscription(ref action);

                action.Execute();
            }
            catch (Exception ex)
            {
                ChatLog.GetInstance().LogException(ex);
            }
        }