public TCPManager(string ipAddress)
        {
            IPAddress = ipAddress;
            // Create message receiver receiving 'MyRequest' and receiving 'MyResponse'.
            aReceiverFactory = new DuplexTypedMessagesFactory();
            myReceiver       = aReceiverFactory.CreateDuplexTypedMessageReceiver <String, String>();

            // Subscribe to handle messages.
            myReceiver.MessageReceived += OnMessageReceived;

            // Create TCP messaging.
            // Note: 192.168.0.100 is the IP from the wireless router (no internet)
            // and 8800 is the socket.
            aMessaging     = new TcpMessagingSystemFactory();
            anInputChannel = aMessaging.CreateDuplexInputChannel(IPAddress);

            // Attach the input channel and start to listen to messages.
            try
            {
                myReceiver.AttachDuplexInputChannel(anInputChannel);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #2
0
        public YZXCMessagingNode(
            YZXMessagingType messagingtype     = YZXMessagingType.Tcp,
            YZXSerializerType serializertype   = YZXSerializerType.Xml,
            YZXMessagesFactoryType factorytype = YZXMessagesFactoryType.Duplex)
        {
            DSenderFactory = new DuplexTypedMessagesFactory();

            DReceiverFactory = new DuplexTypedMessagesFactory();

            switch (messagingtype)
            {
            case YZXMessagingType.Tcp:
                UnderlyingMessaging = new TcpMessagingSystemFactory();
                break;

            case YZXMessagingType.Http:
                UnderlyingMessaging = new HttpMessagingSystemFactory();
                break;

            case YZXMessagingType.WebSocket:
                UnderlyingMessaging = new WebSocketMessagingSystemFactory();
                break;
            }

            switch (serializertype)
            {
            case YZXSerializerType.Xml:
                serializer = new XmlStringSerializer();
                break;

            case YZXSerializerType.Json:
                serializer = new DataContractJsonStringSerializer();
                break;
            }
        }