Files
Max Gortman 4f28a55b48 Move to .NET Core tooling (#170)
Motivation
.NET Core tooling allows building for both .NET Framework and .NET Standard while easing pains of running tests and packaging.

Modifications
- csproj -> xproj + project.json
- support for .NET Standard 1.3
- build script is now based on CAKE
- using dotnet CLI for building, testing, packing
- strong name by default (snk included)

Result
DotNetty works on .NET Core and any other platform supporting .NET Standard 1.3+.
2016-11-07 17:50:24 -08:00

43 lines
1.5 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Echo.Client
{
using System;
using System.Text;
using DotNetty.Buffers;
using DotNetty.Transport.Channels;
using Examples.Common;
public class EchoClientHandler : ChannelHandlerAdapter
{
readonly IByteBuffer initialMessage;
public EchoClientHandler()
{
this.initialMessage = Unpooled.Buffer(ClientSettings.Size);
byte[] messageBytes = Encoding.UTF8.GetBytes("Hello world");
this.initialMessage.WriteBytes(messageBytes);
}
public override void ChannelActive(IChannelHandlerContext context) => context.WriteAndFlushAsync(this.initialMessage);
public override void ChannelRead(IChannelHandlerContext context, object message)
{
var byteBuffer = message as IByteBuffer;
if (byteBuffer != null)
{
Console.WriteLine("Received from server: " + byteBuffer.ToString(Encoding.UTF8));
}
context.WriteAsync(message);
}
public override void ChannelReadComplete(IChannelHandlerContext context) => context.Flush();
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
{
Console.WriteLine("Exception: " + exception);
context.CloseAsync();
}
}
}