示例#1
0
        private void _channel_Receive(object sender, Message <TSender> e)
        {
            var i      = 0;
            var target = 0u;

            for (; i < e.Data.Length; i++)
            {
                var b = e.Data[i];
                target |= ((uint)b & 0x7f) << (7 * i++);
                if ((b & 0x80) != 0x80)
                {
                    break;
                }
            }

            this.Receive?.Invoke(this,
                                 new UserMessage <TSender>(e.Sender, e.IsOwnMessage, target, ByteHelper.SkipBytes(e.Data, i)));
        }
示例#2
0
        public void Send(TSender target, byte[] data)
        {
            var targetBytes = ByteHelper.EncodeVarint(this._identifyCallback(target));

            this._channel.Send(ByteHelper.Combine(targetBytes, data));
        }