Exemplo n.º 1
0
        /// <summary>
        /// 发送聊天内容
        /// </summary>
        public void Send()
        {
            TextBoxA txtData = GetTextBox("txtData");
            ChatData data    = new ChatData();

            data.m_text   = txtData.Text;
            data.m_type   = 0;
            data.m_userID = DataCenter.UserID;
            m_chatService.Send(m_chatService.RequestID, data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 退出弹幕
        /// </summary>
        /// <param name="requestID">请求ID</param>
        /// <param name="args">弹幕数据</param>
        public int Exit(int requestID, ChatData chat)
        {
            List <ChatData> datas = new List <ChatData>();

            datas.Add(chat);
            int ret = SendToAllClients(FUNCTIONID_CHAT_EXIT, requestID, datas);

            datas.Clear();
            return(ret > 0 ? 1 : 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取弹幕信息
        /// </summary>
        /// <param name="datas">用于返回弹幕信息</param>
        /// <param name="body">包体</param>
        /// <param name="bodyLength">包体长度</param>
        /// <returns></returns>
        public static int GetChatDatas(List <ChatData> datas, byte[] body, int bodyLength)
        {
            Binary br = new Binary();

            br.Write(body, bodyLength);
            int size = br.ReadInt();

            for (int i = 0; i < size; i++)
            {
                ChatData chat = new ChatData();
                chat.m_userID = br.ReadInt();
                chat.m_type   = br.ReadChar();
                chat.m_text   = br.ReadString();
                datas.Add(chat);
            }
            br.Close();
            return(1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="state">状态</param>
        /// <returns>加载状态</returns>
        public static int LoadData(int state)
        {
            ChatData chatData = new ChatData();

            m_chatService.Enter(m_chatService.RequestID, chatData);
            Indicator indicator = new Indicator();

            indicator.m_userID = m_userID;
            m_indicatorService.GetIndicators(m_indicatorService.GetListRequestID, indicator);
            SecurityFilterTemplate template = new SecurityFilterTemplate();

            template.m_userID = m_userID;
            m_securityFilterService.GetTemplates(m_securityFilterService.GetListRequestID, template);
            UserSecurityVisitsCount visitsCount = new UserSecurityVisitsCount();

            visitsCount.m_userID = DataCenter.UserID;
            m_userSecurityService.GetVisitsCount(m_userSecurityService.GetListRequestID, visitsCount);
            UserSecurityCategory category = new UserSecurityCategory();

            category.m_userID = m_userID;
            m_userSecurityService.GetCategories(m_userSecurityService.GetListRequestID, category);
            IndicatorLayout indicatorLayout = new IndicatorLayout();

            indicatorLayout.m_userID = m_userID;
            m_indicatorLayoutService.GetLayouts(m_indicatorLayoutService.GetListRequestID, indicatorLayout);
            Macro macro = new Macro();

            macro.m_userID = m_userID;
            m_macroService.GetMacros(m_macroService.GetListRequestID, macro);
            UserSession userSession = new UserSession();

            userSession.m_userID = m_userID;
            m_userSessionService.GetSessions(m_userSessionService.GetListRequestID, userSession);
            if (state == 1)
            {
                m_securityService.LoadSecurities();
            }
            if (m_mainUI != null)
            {
                m_mainUI.LoadData();
            }
            return(0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="userID">方法ID</param>
        /// <param name="userID">请求ID</param>
        /// <param name="text">发送字符</param>
        public int SendToAllClients(int functionID, int requestID, List <ChatData> datas)
        {
            Binary bw       = new Binary();
            int    chatSize = datas.Count;

            bw.WriteInt(chatSize);
            for (int i = 0; i < chatSize; i++)
            {
                ChatData chat = datas[i];
                bw.WriteInt(chat.m_userID);
                bw.WriteChar((char)chat.m_type);
                bw.WriteString(chat.m_text);
            }
            byte[] bytes = bw.GetBytes();
            int    ret   = Send(new CMessage(GroupID, ServiceID, functionID, SessionID, requestID, m_socketID, 0, CompressType, bytes.Length, bytes));

            bw.Close();
            return(ret);
        }