private void SendRequest(byte[] header, byte[] body) { List <byte[]> buffs = new List <byte[]>(); buffs.Add(NetworkProtoParser.SizeToVariant32(header)); buffs.Add(header); buffs.Add(NetworkProtoParser.SizeToVariant32(body)); buffs.Add(body); buffs.Add(new byte[1] { 0 }); foreach (byte[] buff in buffs) { m_socket.Send(buff); } m_isReady = true; }
/// <summary> /// 发送心跳包 /// </summary> /// <returns></returns> private IEnumerator StartHeartBeat() { while (m_HeartBeat) { MessageHeaderRequest.Builder header = MessageHeaderRequest.CreateBuilder(); header.SetName("Heart"); byte[] headerBytes = header.Build().ToByteArray(); List <byte[]> buffs = new List <byte[]>(); buffs.Add(NetworkProtoParser.SizeToVariant32(headerBytes)); buffs.Add(headerBytes); buffs.Add(new byte[1] { 0 }); foreach (byte[] buff in buffs) { m_socket.Send(buff); } yield return(null); } }