예제 #1
0
        private INetContext CreateContext()
        {
            INetContext ctx = new NetContext();

            ctx.ApplicationName = Guid.NewGuid().ToString();
            ctx.IPAddress       = "localhost";
            ctx.MaxConnections  = 10;
            ctx.Port            = 1111;
            ctx.Serializer.AddReaderWriter <TestData>(
                new DataWriter(ctx.Serializer, typeof(TestData)),
                new DataReader(ctx.Serializer, typeof(TestData)));

            ctx.Services.Register <Svc1>();
            ctx.Services.Register <Svc2>();
            ctx.Services.Register <Svc3>();
            ctx.Services.Register <Svc4>();

            ctx.Packets.Register <Pck4>();
            ctx.Packets.Register <Pck3>();
            ctx.Packets.Register <Pck2>();
            ctx.Packets.Register <Pck1>();

            ctx.LockContext();
            return(ctx);
        }