示例#1
0
        private void SendDispatchLoop()
        {
            while (true)
            {
                if (scheduler.Verbose)
                {
                    Console.WriteLine("Waiting for the next send to dispatch");
                }

                SendTask sendTask = sendQueue.Receive();

                if (scheduler.Verbose)
                {
                    Console.WriteLine("Dispatching send of message of size {0} to {1}",
                                      sendTask.Message.Length, IoScheduler.PublicKeyToString(sendTask.DestinationPublicKey));
                }

                SenderThread senderThread = scheduler.FindSenderForDestinationPublicKey(sendTask.DestinationPublicKey);

                if (senderThread == null)
                {
                    senderThread = ClientSenderThread.Create(scheduler, sendTask.DestinationPublicKey);
                }

                senderThread.EnqueueSendTask(sendTask);
            }
        }
示例#2
0
        ///////////////////////////////////
        // Extra API calls for client
        ///////////////////////////////////

        public void Connect(byte[] destinationPublicKey)
        {
            SenderThread senderThread = FindSenderForDestinationPublicKey(destinationPublicKey);

            if (senderThread == null)
            {
                senderThread = ClientSenderThread.Create(this, destinationPublicKey);
            }
        }
示例#3
0
        public static ClientSenderThread Create(IoScheduler scheduler, byte[] destinationPublicKey)
        {
            if (scheduler.Verbose)
            {
                Console.WriteLine("Creating sender thread to send to remote public key {0}",
                                  scheduler.LookupPublicKeyAsString(destinationPublicKey));
            }

            ClientSenderThread senderThread = new ClientSenderThread(scheduler, destinationPublicKey);

            senderThread.Start();
            return(senderThread);
        }