예제 #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));
        }