/// <summary> /// 获取弹幕信息 /// </summary> /// <param name="chatData">聊天信息</param> /// <param name="body">包体</param> /// <param name="bodyLength">包体长度</param> /// <returns></returns> public static int GetChatData(ChatData chatData, byte[] body, int bodyLength) { Binary br = new Binary(); br.Write(body, bodyLength); chatData.m_aes = br.ReadString(); chatData.m_tokens = br.ReadString(); chatData.m_from = br.ReadString(); chatData.m_to = br.ReadString(); chatData.m_content = br.ReadString(); chatData.m_bodyLength = br.ReadInt(); if (chatData.m_bodyLength > 0) { chatData.m_body = new byte[chatData.m_bodyLength]; br.ReadBytes(chatData.m_body); } br.Close(); return(1); }
/// <summary> /// 获取主机信息 /// </summary> /// <param name="body">包体</param> /// <param name="bodyLength">包体长度</param> /// <returns></returns> public static int GetHostInfos(List <ChatHostInfo> datas, ref int type, byte[] body, int bodyLength) { Binary br = new Binary(); br.Write(body, bodyLength); int size = br.ReadInt(); type = br.ReadInt(); for (int i = 0; i < size; i++) { ChatHostInfo data = new ChatHostInfo(); data.m_ip = br.ReadString(); data.m_serverPort = br.ReadInt(); data.m_type = br.ReadInt(); data.m_userID = br.ReadString(); data.m_userName = br.ReadString(); datas.Add(data); } br.Close(); return(1); }