Ejemplo n.º 1
0
        public OneAppTcpServer(int port)
        {
            _port      = port;
            _ipAddress = CommunicationUtils.GetMyIpAddress();

            _requestHandlers = new Dictionary <string, TcpRequestHandlerDelegate>();

            _listener = new TcpListener(_ipAddress, _port);
        }
        public static void Start()
        {
            OneAppTcpClient client = new OneAppTcpClient(CommunicationUtils.GetMyIpAddress(), 8080);

            var data = new
            {
                id      = "test",
                message = "hello from client"
            };

            var request = new TcpRequest()
            {
                url     = FmsUrl.RegisterPod,
                payload = JsonConvert.SerializeObject(data)
            };

            void OnResponse(TcpResponse response)
            {
                Console.WriteLine($"Response: {response.payload}");
            }

            client.SendRequest(request, OnResponse);
        }