Beispiel #1
0
        /// <summary>
        /// Sends a message with the supplied header, and payload
        /// </summary>
        /// <param name="p_Object">Header</param>
        /// <param name="p_Payload">Payload data</param>
        public void SendMessage(RpcMessageHeader p_Object, byte[] p_Payload)
        {
            var s_Bits       = p_Object.ToUInt64();
            var s_HeaderData = SerializeObject(s_Bits);

            using (var s_Writer = new BinaryWriter(m_Client.GetStream(), Encoding.ASCII, true))
            {
                s_Writer.Write(s_HeaderData);
                s_Writer.Write(p_Payload);
            }
        }
Beispiel #2
0
        public (RpcMessageHeader, byte[]) ReceiveObjectAndPayload()
        {
            using (var s_Reader = new BinaryReader(m_Client.GetStream(), Encoding.ASCII, true))
            {
                var s_Header = new RpcMessageHeader(s_Reader.ReadUInt64());

                var s_PayloadSize = (ushort)(s_Header.PayloadSize > c_BufferSize ? c_BufferSize : s_Header.PayloadSize);

                var s_Payload = s_Reader.ReadBytes(s_PayloadSize);

                return(s_Header, s_Payload);
            }
        }