Example #1
0
        public void Receive(Connection con)
        {
            if (con.handler.Connected)
            {
                length = BitConverter.ToInt32(con.Receive(0), 0);
                con.Send(0, new byte[1]);

                values = con.Receive(0);
                con.Send(0, new byte[1]);
            }
        }
Example #2
0
        public void Send(Connection con)
        {
            if (con.socket.Connected)
            {
                con.Send(1, BitConverter.GetBytes(length));
                con.Receive(1);

                con.Send(1, values);
                con.Receive(1);
            }
        }
        public void Send(Connection con)
        {
            if (con.socket.Connected)
            {
                con.Send(1, amount.ToByteArray());
                con.Receive(1);

                con.Send(1, id.ToByteArray());
                con.Receive(1);

                con.Send(1, BitConverter.GetBytes(s_series.Count()));
                con.Receive(1);

                for (int i = 0; i < s_series.Count(); i++)
                {
                    con.Send(1, s_series[i].ToByteArray());
                    con.Receive(1);

                    con.Send(1, t_series[i].ToByteArray());
                    con.Receive(1);

                    con.Send(1, u_hashes[i].ToByteArray());
                    con.Receive(1);

                    con.Send(1, w_hashes[i].ToByteArray());
                    con.Receive(1);
                }

                Console.WriteLine("\t[debug]: Banknote sent.");
            }
        }
        public void Receive(Connection con)
        {
            if (con.handler.Connected)
            {
                var result = con.Receive(0);
                amount = new BigInteger(result);
                con.Send(0, new byte[1]);

                result = con.Receive(0);
                id = new BigInteger(result);
                con.Send(0, new byte[1]);

                var no_series = BitConverter.ToInt32(con.Receive(0), 0);
                con.Send(0, new byte[1]);

                for (int i = 0; i < no_series; i++)
                {
                    result = con.Receive(0);
                    con.Send(0, new byte[1]);
                    s_series.Add(new BigInteger(result));

                    result = con.Receive(0);
                    con.Send(0, new byte[1]);
                    t_series.Add(new BigInteger(result));

                    result = con.Receive(0);
                    con.Send(0, new byte[1]);
                    u_hashes.Add(new BigInteger(result));

                    result = con.Receive(0);
                    con.Send(0, new byte[1]);
                    w_hashes.Add(new BigInteger(result));
                }

                Console.WriteLine("\t[debug]: Banknote received.");
            }
        }