Beispiel #1
0
        public void Initialize(ITraceProvider traceProvider)
        {
            TcpChannel channel = new TcpChannel(_server, _port, _bindIP, traceProvider);

            channel.Formatter = GetChannelFormatter();
            RequestManager requestManager = new RequestManager(channel, _channelDisconnected);

            channel.Connect();
            _requestManager = requestManager;

            try
            {
                initialized = InitializeInternal();
            }
            catch (Exception)
            {
                channel.Disconnect();
                _requestManager = null;
                throw;
            }

            if (!initialized)
            {
                channel.Disconnect();
                _requestManager = null;
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start..");
            Console.ReadKey();

            Server = new TcpChannel();

            Timer = new Timer(OnTick, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(50));

            Server.EventInform += (s, e) => Console.WriteLine(e.Data.Message);
            Server.GetInform += (s, e) => Console.WriteLine("Got: {0}", e.Data.Value);
            Server.CheckInform += (s, e) => Console.WriteLine(e.Data.Success);

            Server.GetAllInform += (s, e) =>
            {
                Console.WriteLine("Test: Data Coherence Test...");
                foreach (var entity in e.Data.Table)
                {
                    // Check the entity
                    Server.Check(entity.Key, entity.Value);
                }
            };

            Server.Connected += (s, e) =>
            {
                Server.GetAll();
            };
            Server.Connect("127.0.0.1", 8002);

            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
        }
Beispiel #3
0
        public static IConnection <TContract, TcpChannel> CreateTcpClientConnection <TContract>(
            this PresentationBuilder <TContract> builder, IPEndPoint endPoint)
            where TContract : class

        {
            return(builder.UseChannel(() =>
            {
                var channel = new TcpChannel();
                channel.Connect(endPoint);
                return channel;
            }).Build());
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var Server = new TcpChannel(1000000);

            Server.EventInform += (sender, packet) => Console.WriteLine(packet.Message);
            Server.GetInform += (sender, packet) => Console.WriteLine("Got: {0}", packet.Value);
            Server.CheckInform += (sender, packet) =>
            {
                //if(!packet.Success)
                    Console.WriteLine("[{0}] {1} => {2}", packet.Success ? "SUCCESS" : "FAIL", packet.Key, packet.Value);
            };

            Server.GetAllInform += async (sender, packet) =>
            {
                Console.WriteLine("Test: Data Coherence Test...");
                foreach (var entity in packet.Table)
                    await Server.Check(entity.Key, entity.Value);
            };

            Server.Connected += async (sender) =>
            {
                Console.WriteLine("Connected");
                await sender.GetAll();
            };

            Server.Disconnected += (sender, error) =>
            {
                Console.WriteLine("Disconnected : {0}", error);
            };

            Task.Run(async () => await Server.Connect("127.0.0.1", 8002));

            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
            Server.Disconnect();
        }