public int Size() { int size = 0; size += Gobuf.VarintSize(this.C); return(size); }
public void Send(byte serviceId, byte messageId, byte[] content) { try { byte[] buffer = new byte[packetHeadSize + content.Length]; int n = 0; Gobuf.WriteUint32((uint)content.Length, buffer, ref n); buffer[n++] = serviceId; buffer[n++] = messageId; Buffer.BlockCopy(content, 0, buffer, n, content.Length); this.stream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(SendCallback), this.stream); } catch (Exception e) { Console.WriteLine(e); this.Close(); } }
public int Unmarshal(byte[] b, int n) { this.C = Gobuf.ReadVarint(b, ref n); return(n); }
public int Marshal(byte[] b, int n) { Gobuf.WriteVarint(this.C, b, ref n); return(n); }