Beispiel #1
0
        private void TalkToUser(string myName, string userName)
        {
            OutputPipe op = ConnectToUser(userName);

            if (op != null)
            {
                textWriter.WriteLine("Welcome to JXTA-C Chat, " + userName);
                textWriter.WriteLine("Type a '.' at begining of line to quit.");

                String userMessage = "";

                while (true)
                {
                    userMessage = textReader.ReadLine();
                    if (userMessage != "")
                    {
                        if (userMessage[0] == '.')
                        {
                            break;
                        }
                        SendMessage(op, myName, userMessage);
                    }
                }
            }
        }
Beispiel #2
0
        public void SendMessage(OutputPipe op, string myName, string userMessage)
        {
            Message msg = new Message();

            msg.AddMessageElement(new MessageElement("JxtaTalkSenderName", "text/plain", myName));
            msg.AddMessageElement(new MessageElement("GrpName", "text/plain", "NetPeerGroup"));
            msg.AddMessageElement(new MessageElement("JxtaTalkSenderMessage", "text/plain", userMessage));

            op.Send(msg);
        }
Beispiel #3
0
        public IEnumerable <string> Serialize()
        {
            yield return(AssemblyPath.NativePath);

            yield return(InputPipe.ToString());

            yield return(OutputPipe.ToString());

            yield return(UserDataPath.ToString());
        }
Beispiel #4
0
        public OutputPipe ConnectToUser(string userName)
        {
            PipeAdvertisement adv = GetUserAdv(userName, 1 * 5 * 1000 * 1000);

            if (adv != null)
            {
                OutputPipe op = pipeservice.CreateOutputPipe(adv, 30 * 1000);

                if (op == null)
                {
                    textWriter.WriteLine("peer not found.");
                    return(null);
                }

                _outputPipe.Add(userName, op);

                return(op);
            }
            return(null);
        }
Beispiel #5
0
 public void Close()
 {
     _threwException = true;
     InputPipe.Close();
     OutputPipe.Close();
 }