Ejemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (connectionResult == ConnectionResult.Connected)
     {
         Console.WriteLine($"{tcpConnection.ToString()} Connection established");
         //3. Send a raw data packet request.
         tcpConnection.SendRawData(RawDataConverter.FromUTF8String("HelloWorld", "Hello, this is the RawDataExample!"));
         //tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", true));
         //tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", false));
         //tcpConnection.SendRawData(RawDataConverter.FromDouble("DoubleValue", 32.99311325d));
         ////4. Send a raw data packet request without any helper class
         //tcpConnection.SendRawData("HelloWorld", Encoding.UTF8.GetBytes("Hello, this is the RawDataExample!"));
         //tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(true));
         //tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(false));
         //tcpConnection.SendRawData("DoubleValue", BitConverter.GetBytes(32.99311325d));
     }
 }
Ejemplo n.º 2
0
        public void Demo()
        {
            ConnectionResult connectionResult = ConnectionResult.TCPConnectionNotAlive;
            //1. Establish a connection to the server.
            TcpConnection tcpConnection = ConnectionFactory.CreateTcpConnection("127.0.0.1", 1234, out connectionResult);

            //2. Register what happens if we get a connection
            if (connectionResult == ConnectionResult.Connected)
            {
                Console.WriteLine($"{tcpConnection.ToString()} Connection established");
                //3. Send a raw data packet request.
                tcpConnection.SendRawData(RawDataConverter.FromUTF8String("HelloWorld", "Hello, this is the RawDataExample!"));
                tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", true));
                tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", false));
                tcpConnection.SendRawData(RawDataConverter.FromDouble("DoubleValue", 32.99311325d));
                //4. Send a raw data packet request without any helper class
                tcpConnection.SendRawData("HelloWorld", Encoding.UTF8.GetBytes("Hello, this is the RawDataExample!"));
                tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(true));
                tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(false));
                tcpConnection.SendRawData("DoubleValue", BitConverter.GetBytes(32.99311325d));
            }
        }
 public static void SendMessge(this ClientConnectionContainer client, string Tag, object data)
 {
     client.Send(RawDataConverter.FromUTF8String(Tag, data.ToJson()));
 }