Пример #1
0
func main() {
	//var maxIdleTime int64 = 60*60*24	// 24 hours
	fmt.Println(TAG, "start...")
	rtcchat2.GkvInit()

	now := time.Now()
	rtcchat2.C.VisitItemsAscend([]byte(""), true, func(i *gkvlite.Item) bool {
		// This visitor callback will be invoked with every item
		// If we want to stop visiting, return false;
		key := string(i.Key)
		user := rtcchat2.GkvGet(key)

		// show the create-age and idle-age in seconds
		ageCreated := now.Unix() - user.Created.Unix()
		ageIdle := now.Unix() - user.LastAccessed.Unix()
		fmt.Println("Key", key,
			"Val", user.Value,
			"Crea", ageCreated,
			"Last", ageIdle,
			"C", user.Counter,
			user.AutoAnswer, user.Flag2, user.Flag3, user.Int1, user.Int2, user.Int3)
		/*if(ageIdle>maxIdleTime) {
			fmt.Println("Key",key,"is inactive too long; may be removed")
			rtcchat2.C.Delete(i.Key)
			rtcchat2.S.Flush()
			rtcchat2.F.Sync()
		}*/
		return true
	})
}
Пример #2
0
func main() {
	var secure = flag.Bool("secure", true, "set false to make redirect use http instead of https")
	var sigport = flag.Int("sigport", 8077, "set port for client signaling ")
	var callerport = flag.Int("callerport", 8000, "set port for redirect service")
	var stunport = flag.Int("stunport", 19253, "set STUN port")
	var stunhost = flag.String("stunhost", "", "set STUN host redirect (empty=>weburl,non-empty=>no service)")
	var ringtone = flag.String("ringtone", "", "set newroom ringtone (e.g. -newroom=sample/ring.ogg)")
	flag.Usage = func() {
		flag.PrintDefaults()
		os.Exit(0)
	}
	flag.Parse()

	fmt.Println("sigport", *sigport)
	fmt.Println("callerport", *callerport)
	fmt.Println("stunport", *stunport)

	rtcchat2.GkvInit()

	// StunUDP (default port 19253 = stunport)
	go rtcchat2.StunUDP(*stunhost, *stunport)

	// RtcSignaling (default port 8077 = sigport)
	// makes use of "html/signaling/*"
	go rtcchat2.RtcSignaling(*secure, *sigport, *stunport, *stunhost, *ringtone)

	// CalleeService (default port 8078 = sigPort+1) allows a callee to wait for and receive chat calls
	// makes use of "html/callee/*"
	go rtcchat2.CalleeService(*secure, *sigport, *callerport, "auto")

	// CallerService (default port 8000 = callerport) allows other clients to "call" admin clients
	// makes use of "html/caller-enter-name/*" and "html/callee-unavailable/*"
	go rtcchat2.CallerService(*secure, *callerport, *sigport)

	go rtcchat2.BGCleaner()

	// let services run til aborted
	select {}
}
Пример #3
0
func main() {
	fmt.Println(TAG, "start...")
	rtcchat2.GkvInit()

	var user rtcchat2.UserInfo
	var key string

	key = "f3e2-01d2-1f66-0cd3"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "01d2-f3e2-d332-164d"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "e6a2-dde2-d1f2-1622"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "d9a6-c4e4-2231-8a3d"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)
}