Example #1
0
        /// <summary>
        /// Occurs when the user clicks the Dial button.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">An <see cref="System.EventArgs"/> containing event data.</param>
        private void DialButton_Click(object sender, EventArgs e)
        {
            StatusTextBox.Clear();

            // This button will be used to dial the connection.
            Dialer.EntryName     = EntryName;
            Dialer.PhoneBookPath = PHONE_BOOK_PATH;

            try
            {
                // Set the credentials the dialer should use.
                Dialer.Credentials = new NetworkCredential("Test", "User");

                // NOTE: The entry MUST be in the phone book before the connection can be dialed.
                // Begin dialing the connection; this will raise events from the dialer instance.
                handle = Dialer.DialAsync();

                // Enable the disconnect button for use later.
                DisconnectButton.Enabled = true;
            }
            catch (Exception ex)
            {
                StatusTextBox.AppendText(ex.ToString());
            }
        }
Example #2
0
        public void WrongOrderRepReq()
        {
            Socket rep0;
            var    errno = Protocols.Rep0(out rep0);

            Assert.IsTrue(errno == 0);
            Socket req0;

            errno = Protocols.Req0(out req0);
            Assert.IsTrue(errno == 0);
            Dialer dialer;

            errno = Dialer.Dial(req0, "ipc:///myFirstPipe1234", out dialer, Flag.nonblock);
            // Assert.IsTrue(errno == 0);
            System.Threading.Thread.Sleep(100);
            Listener listener;

            errno = Listener.Listen(rep0, "ipc:///myFirstPipe1234", out listener, 0);
            Assert.IsTrue(errno == 0);

            errno = req0.Send(new byte[] { 1, 2, 3, 4 }, Flag.none);
            Assert.IsTrue(errno == 0);
            byte[] data;
            byte[] data2;
            rep0.Receive(out data, 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            rep0.Send(data);
            req0.Receive(out data2, 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            Assert.IsTrue(req0.Close() == 0);
            Assert.IsTrue(rep0.Close() == 0);
        }
Example #3
0
 public Agent()
 {
     Client.Log.SetVerbosityLevel(0);
     _client = new Client();
     _hub    = new Hub(_client);
     _dialer = new Dialer(_client, _hub);
 }
Example #4
0
        public void DijkstraBus()
        {
            sockets    = new Socket[n];
            potentials = new int[n];
            dialers    = new Dialer[n, 2];
            receivers  = new Aio[n];
            senders    = new Aio[n];
            listeners  = new Listener[n];

            random = new Random(1);

            for (int i = 0; i < n; i++)
            {
                Protocols.Bus0(out sockets[i]);
                listeners[i]  = new Listener(sockets[i], "ipc:///Dijkstra" + i.ToString());
                potentials[i] = int.MaxValue;
            }

            // every node connects to two other random nodes
            for (int i = 0; i < n; i++)
            {
                int target = random.Next(n);
                dialers[i, 0] = new Dialer(sockets[i], "ipc:///Dijkstra" + target.ToString());
                target        = random.Next(n);
                dialers[i, 1] = new Dialer(sockets[i], "ipc:///Dijkstra" + target.ToString());
            }

            // arm the aios
            for (int i = 0; i < n; i++)
            {
                senders[i]   = new Aio(Whatever, i);
                receivers[i] = new Aio(Received, i);
                sockets[i].Receive(receivers[i]);
            }
            Msg msg = new Msg(0);

            msg.AppendU32(0);
            potentials[0] = 0;
            sockets[0].Send(msg);
            //msg.Dispose();
            int oldCount = 0;

            for (;;)
            {
                System.Threading.Thread.Sleep(100);
                if (countReceived > oldCount)
                {
                    oldCount = countReceived;
                }
                else
                {
                    break;
                }
            }
            for (int i = 0; i < n; i++)
            {
                sockets[i].Close();
            }
            return;
        }
Example #5
0
        public void TrivialRepReq()
        {
            Socket rep0;
            var    errno = Protocols.Rep0(out rep0);

            Assert.IsTrue(errno == 0);
            Socket req0;

            errno = Protocols.Req0(out req0);
            Assert.IsTrue(errno == 0);
            Listener listener;

            errno = Listener.Listen(rep0, "ipc:///myFirstPipe1234", out listener, 0);
            Assert.IsTrue(errno == 0);
            Dialer dialer;

            errno = Dialer.Dial(req0, "ipc:///myFirstPipe1234", out dialer, 0);
            Assert.IsTrue(errno == 0);
            req0.Send(new byte[] { 1, 2, 3, 4 }, 0);
            byte[] data;
            byte[] data2;
            rep0.Receive(out data, 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            rep0.Send(data);
            req0.Receive(out data2, 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            Assert.IsTrue(req0.Close() == 0);
            Assert.IsTrue(rep0.Close() == 0);
        }
        public async Task <IActionResult> Edit(int id, [Bind("DialerId,DialerName,DialerAddress,TelNumber")] Dialer dialer)
        {
            if (id != dialer.DialerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dialer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DialerExists(dialer.DialerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dialer));
        }
Example #7
0
 public BaseClient()
 {
     _storage = new Storage(Extentions.GetExecutionPath().FullName);
     Client.Log.SetFilePath(Path.Combine(_storage.LogDirectory, "tdlib.log"));
     Client.Log.SetMaxFileSize(1_000_000); // 1MB
     Client.Log.SetVerbosityLevel(3);
     _client = new Client();
     _hub    = new Hub(_client);
     _dialer = new Dialer(_client, _hub);
     _agent  = new Agent(_hub, _dialer);
 }
        public async Task <IActionResult> Create([Bind("DialerId,DialerName,DialerAddress,TelNumber")] Dialer dialer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dialer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dialer));
        }
Example #9
0
        void RPCClientStart()
        {
            Errno errno;

            errno = Protocols.Req0(out req0);
            Assert.IsTrue(errno == Errno.ok);
            errno = req0.SetOptInt("raw", 1);
            Assert.IsTrue(errno == Errno.ok);
            errno = Dialer.Dial(req0, "ipc:///myfirstpipe12345", out dialer, 0);
            Assert.IsTrue(errno == Errno.ok);
            errno = Aio.Alloc(out clientAio, RPCClientCallback, null);
            Assert.IsTrue(errno == Errno.ok);
            req0.Receive(clientAio);
        }
Example #10
0
        /// <summary>
        /// Occurs when the user clicks the Disconnect button.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">An <see cref="System.EventArgs"/> containing event data.</param>
        private void DisconnectButton_Click(object sender, EventArgs e)
        {
            if (Dialer.IsBusy)
            {
                // The connection attempt has not been completed, cancel the attempt.
                Dialer.DialAsyncCancel();
            }
            else
            {
                // The connection attempt has completed, attempt to find the connection in the active connections.
                var connection = RasConnection.GetActiveConnections().FirstOrDefault(_ => _.Handle == handle);

                // The connection has been found, disconnect it.
                connection?.HangUp();
            }
        }
Example #11
0
        public void ServerDeathRepReq()
        {
            Socket rep0;
            var    errno = Protocols.Rep0(out rep0);

            Assert.IsTrue(errno == 0);
            Socket req0;

            errno = Protocols.Req0(out req0);
            Assert.IsTrue(errno == 0);
            Listener listener;

            errno = Listener.Listen(rep0, "ipc:///myFirstPipe1234", out listener, 0);
            Assert.IsTrue(errno == 0);
            Dialer dialer;

            errno = Dialer.Dial(req0, "ipc:///myFirstPipe1234", out dialer, 0);
            Assert.IsTrue(errno == 0);
            req0.Send(new byte[] { 1, 2, 3, 4 }, 0);
            byte[] data;
            byte[] data2;
            rep0.Receive(out data, 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            rep0.Close(); // that's unexpected.
            System.Threading.Thread.Sleep(500);

            // server restart
            errno = Protocols.Rep0(out rep0);
            Assert.IsTrue(errno == 0);
            errno = Listener.Listen(rep0, "ipc:///myFirstPipe1234", out listener, 0);
            Assert.IsTrue(errno == 0);
            errno = rep0.Receive(out data, 0);
            Assert.IsTrue(errno == 0);
            errno = rep0.Send(data);
            Assert.IsTrue(errno == 0);

            errno = req0.Receive(out data2, 0);
            Assert.IsTrue(errno == 0);
            Assert.IsTrue(data.SequenceEqual(new byte[] { 1, 2, 3, 4 }));
            Assert.IsTrue(req0.Close() == 0);
            Assert.IsTrue(rep0.Close() == 0);
        }
Example #12
0
 public Agent(Hub hub, Dialer dialer)
 {
     _hub    = hub;
     _dialer = dialer;
 }
Example #13
0
 public IDialer DialerCreate(ISocket socket, string url) => Dialer.Create(socket, url);
Example #14
0
 public sysDialer(Dialer Dialer = default, @string network = default, @string address = default)
 {
     this.m_DialerRef = new ptr <Dialer>(Dialer);
     this.network     = network;
     this.address     = address;
 }