Ejemplo n.º 1
0
        /// <summary>
        /// 发送消息 ,服务器接收的是CSChatMessage实体,他包含发送人,接收人,消息内容等信息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public Task ClientSendMsgToClient(CSChatMessage msg)
        {
            var groupName = MessageUtils.GetGroupName(msg.fromuser.userid.ToString(), msg.touser.userid.ToString());

            /*
             * 中间处理一下消息直接转发给(A,B所在组织,即聊天窗口)
             */
            msg.other   = new { t = MessageConfig.ClientTypeCTC };
            msg.msgtype = CSMessageType.Custom;//消息类型为普通消息
            return(Clients.Group(groupName).receiveMessage(msg));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送消息 (群组),服务器接收的是CSChatMessage实体,他包含发送人,接收人,消息内容等信息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public Task ClientSendMsgToGroup(CSChatMessage msg)
        {
            //获取要推送的组织名称
            var groupName = MessageUtils.GetGroupName(msg.touser.userid.ToString());

            //附加信息,为群信息
            msg.other = new { t = MessageConfig.ClientTypeCTG };
            //普通信息类型
            msg.msgtype = CSMessageType.Custom;
            return(Clients.Group(groupName).receiveMessage(msg));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取系统消息
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static CSChatMessage GetSystemMessage(string groupName, string msg, object other = null)
        {
            CSChatMessage chatMsg = new CSChatMessage
            {
                fromuser = GetSystemUser(groupName),
                msg      = msg,
                msgtype  = CSMessageType.System,
                other    = other
            };

            return(chatMsg);
        }
Ejemplo n.º 4
0
    public void SendText(ChatChannelType type, string msg)
    {
        if (msg.Length >= 1 && msg.StartsWith("."))
        {
            string commend = "";
            commend = msg.Remove(0, 1);
            if (string.IsNullOrEmpty(commend) || string.IsNullOrEmpty(commend))
            {
                return;
            }

            string[] paras = commend.Split(new string[] { " " }, System.StringSplitOptions.None);

            if (paras.Length <= 0)
            {
                return;
            }

            if (mParamList == null)
            {
                mParamList = new ArrayList();
            }
            else
            {
                mParamList.Clear();
            }

            for (int i = 1; i < paras.Length; i++)
            {
                mParamList.Add(paras[i]);
            }

            if (!GMHandler.Instance.DoHandler(PlayerController.Instance.GetControlObj(), paras[0], mParamList))
            {
                GMActionParam param = new GMActionParam();
                param.Cmd = commend;

                Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_GM, param);
            }
        }
        else
        {
            //系统频道不允许玩家发送
            if (type == ChatChannelType.ChannelType_System)
            {
                return;
            }

            PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();
            if (module == null)
            {
                return;
            }

            MainFlow mainFlow = GameApp.Instance.GetCurFlow() as MainFlow;
            if (mainFlow != null)
            {
                CSChatMessage packet = new CSChatMessage();
                packet.channel_type = (int)type;
                packet.name         = module.GetName();
                packet.msg          = msg;

                mainFlow.SendToChatServer(packet);
            }
            Role role = PlayerController.Instance.GetControlObj() as Role;
            if (role != null)
            {
                role.Talk(msg);
            }
        }
    }