예제 #1
0
func writeBson(conn net.Conn, m map[string]interface{}) {
	var pkt []byte
	pkt, err := mongo.Encode(pkt, m)
	if err != nil {
		fmt.Println("writeBson Error", err)
		return
	}
	conn.Write(pkt)
}
예제 #2
0
func main() {
	conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", HOST, PORT))
	checkError(err)

	defer conn.Close()

	var loginPkt []byte
	loginPkt, err2 := mongo.Encode(loginPkt, map[string]interface{}{
		"type": "login",
		"id":   ID,
		"pass": PASS,
	})

	checkError(err2)

	conn.Write(loginPkt)

	doClient(conn)

}