private static void ReadGroups() { try { Binary bi = HttpGetService.GetAsBinary(DataCenter.ServerAddr + "giraservice?func=readgroup"); if (bi != null) { String xmlString = bi.ReadString(); if (xmlString != null) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlString); XmlNode node = xmlDoc.DocumentElement; foreach (XmlNode subNode in node.ChildNodes) { if (subNode.Name.ToUpper() == "GROUP") { JGroup jGroup = new JGroup(); jGroup.ReadXml(subNode); m_groups.Add(jGroup); } } } } } catch (Exception ex) { ErrorException.OnError(ex); } }
/// <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); }
public static void InitServer() { m_dataDic = new Dictionary <string, string>(); Binary binary = HttpGetService.GetAsBinary(DataCenter.ServerAddr + "giraservice?func=getall"); if (binary != null) { int dataLength = binary.ReadInt(); for (int i = 0; i < dataLength; i++) { String xmlName = binary.ReadString(); int nextBisLen = binary.ReadInt(); byte[] byts = new byte[nextBisLen]; binary.ReadBytes(byts); String xmlStr = System.Text.Encoding.Default.GetString(byts); m_dataDic[xmlName] = xmlStr; } } }