go get github.com/ddddddO/sip
import (
"io"
"log"
"os"
"github.com/ddddddO/sip"
)
func XXXXX() {
enableServer := true
enableClient := false
laddr := "localhost:5060"
clientCnt := 1
availableSessions := sip.GetAvailableSessions(sip.NewConfig(
enableServer, laddr, clientCnt, // for Server setup
enableClient, nil, // for Client setup
))
for i := range availableSessions {
func(ss *sip.Session) {
// send to client
if _, err := ss.Write([]byte("Hello! by server..\n")); err != nil {
panic(err)
}
// recieve from client
io.Copy(os.Stdout, ss)
}(availableSessions[i])
}
}
import (
"io"
"log"
"os"
"github.com/ddddddO/sip"
)
func YYYYY() {
enableServer := false
enableClient := true
raddrs := []string{"localhost:5060"}
availableSessions := sip.GetAvailableSessions(sip.NewConfig(
enableServer, "", 0, // for Server setup
enableClient, raddrs, // for Client setup
))
for i := range availableSessions {
func(ss *sip.Session) {
// send to server
if _, err := ss.Write([]byte("Hey! by client!\n")); err != nil {
panic(err)
}
// recieve from server
io.Copy(os.Stdout, ss)
}(availableSessions[i])
}
}
github.com/ddddddO/sip/example/pattern1
github.com/ddddddO/sip/example/pattern2