Example #1
0
        public InputPipe CreateInputPipe(PipeAdvertisement adv, PipeMsgListener pipeListener)
        {
            InputPipeImpl pipe = (InputPipeImpl)CreateInputPipe(adv);

            pipe.AddListener(pipeListener);

            return(pipe);
        }
Example #2
0
        /// <summary>
        /// Add a receive listener to a pipe. The listener is invoked for each received
        /// message.
        /// </summary>
        /// <param name="pListener"></param>
        internal void AddListener(PipeMsgListener pListener)
        {
            if (pipeListener != null)
            {
                throw new JxtaException(Errors.JXTA_BUSY);
            }
            if (this.self == IntPtr.Zero)
            {
                throw new JxtaException(Errors.JXTA_FAILED);
            }

            pipeListener = pListener;
            msgListener  = new Listener <MessageImpl>(MessageListener, 1, 200);
            Errors.check(jxta_inputpipe_add_listener(this.self, msgListener.self));
            msgListener.Start();
        }
Example #3
0
        public void LoginUser(string userName, PipeMsgListener talkMessageListener)
        {
            PipeAdvertisement adv = GetUserAdv(userName, 30 * 1000 * 1000);

            if (_userDictionary.ContainsKey(userName) == true)
            {
                textWriter.WriteLine("User " + userName + " is already logged in!!!");
                return;
            }

            if (adv != null)
            {
                InputPipe inputPipe = pipeservice.CreateInputPipe(adv, talkMessageListener);

                // Releasing of these objects are prevented by this container.
                _userDictionary.Add(userName, inputPipe);
            }
            else
            {
                textWriter.WriteLine("Cannot retrieve advertisement for " + userName);
            }
        }