Example #1
0
        public async Task SendMultiple(object[] messages)
        {
            if (!messages.Any())
            {
                throw new ArgumentNullException();
            }

            await ClientSocket.SendAsync(new ArraySegment <byte>(SerDesManager.Serialize(messages)), SocketFlags.None);

            foreach (var message in messages)
            {
                Write($"{message} sended");
            }
        }
Example #2
0
        public async Task Send <T>(T message)
        {
            try
            {
                var buffer = SerDesManager.Serialize(message);

                await ClientSocket.SendAsync(new ArraySegment <byte>(buffer), SocketFlags.None);

                Write($"{message.GetType().Name} sent");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }