Implemented writing to the remote. Now we have bidirectional communication.
// Copyright 2011 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.packagemainimport("cjyar/xmpp""flag""fmt""log""os")// Demonstrate the API, and allow the user to interact with an XMPP// server via the terminal.funcmain(){varjidxmpp.JIDflag.Var(&jid,"jid","JID to log in as")varpw*string=flag.String("pw","","password")flag.Parse()ifjid.Domain==""||*pw==""{flag.Usage()os.Exit(2)}c,err:=xmpp.NewClient(&jid,*pw)iferr!=nil{log.Fatalf("NewClient(%v): %v",jid,err)}deferc.Close()gofunc(ch<-chaninterface{}){forobj:=rangech{fmt.Printf("s: %v\n",obj)}fmt.Println("done reading")}(c.In)ch:=make(chaninterface{})goxmpp.ReadXml(os.Stdin,ch,false)forx:=rangech{fmt.Printf("c: %v",x)c.Out<-x}fmt.Println("done sending")}