public override int write(string path, int flags, string buffer, int offset, int length) { if (getWorkPathArray(path)[1] == "contacts") { Console.WriteLine("looking for contacts:" + getNewfileName(path)); return(0); } else if (getWorkPathArray(path)[1] == "chats") { Console.WriteLine("looking for chats:" + getNewfileName(path) + " : " + buffer); xmppManager.xmpp.Send(new agsXMPP.protocol.client.Message("*****@*****.**", MessageType.chat, buffer)); return(0); } else if (getWorkPathArray(path)[1] == "nodes") { Console.WriteLine("write received:" + buffer); AgIXML agiMsg = new AgIXML("tput", "/home"); Jid to = new Jid("*****@*****.**"); Message msg = new Message(); msg.To = to; msg.AddChild(agiMsg); xmppManager.xmpp.Send(msg); return(0); } else { return(errors.READ_ONLY); } }
public override int write(string path, int flags, string buffer, int offset, int length) { if (getWorkPathArray(path)[1] == "contacts") { Console.WriteLine("looking for contacts:" + getNewfileName(path)); return 0; } else if (getWorkPathArray(path)[1] == "chats") { Console.WriteLine("looking for chats:" + getNewfileName(path)+" : " + buffer); xmppManager.xmpp.Send(new agsXMPP.protocol.client.Message("*****@*****.**", MessageType.chat, buffer)); return 0; } else if (getWorkPathArray(path)[1] == "nodes") { Console.WriteLine("write received:" + buffer); AgIXML agiMsg = new AgIXML("tput", "/home"); Jid to = new Jid("*****@*****.**"); Message msg = new Message(); msg.To = to; msg.AddChild(agiMsg); xmppManager.xmpp.Send(msg); return 0; } else return errors.READ_ONLY; }
static void Xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (msg.HasTag(typeof(AgIXML))) { AgIXML agiMsg = msg.SelectSingleElement(typeof(AgIXML)) as AgIXML; agiMsg newMsg = new agiMsg(); newMsg.ID = agiMsg.ID; newMsg.Type = agiMsg.Type; newMsg.Path = agiMsg.Path; newMsg.SessionID = agiMsg.SessionID; newMsg.SessionKey = agiMsg.SessionKey; newMsg.Data = agiMsg.Data; newMsg.Flags = agiMsg.Flags; switch (newMsg.Type) { case "tput": xmppManager.world.agi.tput(newMsg); break; case "rput": xmppManager.world.agi.rput(newMsg); break; case "tget": xmppManager.world.agi.tget(newMsg); break; case "rget": xmppManager.world.agi.rget(newMsg); break; case "tattach": xmppManager.world.agi.tattach(newMsg); break; case "rattach": xmppManager.world.agi.rattach(newMsg); break; case "tremove": xmppManager.world.agi.tremove(newMsg); break; case "rremove": xmppManager.world.agi.rremove(newMsg); break; case "tflush": xmppManager.world.agi.tflush(newMsg); break; case "rflush": xmppManager.world.agi.rflush(newMsg); break; } } if (msg.Body != null) { messages newMsg = new messages(); newMsg.body = msg.Body; newMsg.from = msg.From.User; int count = 0; while (chats.Count != 0 && count < chats.Count) { if (chats.ElementAt(count).chatWith.userID == msg.From.User) { chats.ElementAt(count).msgChain.Add(newMsg); return; } count++; } chat newchat = new chat(); newchat.msgChain.Add(newMsg); newchat.chatWith.userID = msg.From.User.ToString(); chats.Add(newchat); Console.WriteLine(newMsg.body.ToString()); } }