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); } } } }
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); }
public IEnumerable <string> Serialize() { yield return(AssemblyPath.NativePath); yield return(InputPipe.ToString()); yield return(OutputPipe.ToString()); yield return(UserDataPath.ToString()); }
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); }
public void Close() { _threwException = true; InputPipe.Close(); OutputPipe.Close(); }