Exemplo n.º 1
0
Arquivo: rpc.go Projeto: sinuos/goim
// Connect auth and registe login
func (r *RPC) Connect(args *lproto.ConnArg, rep *lproto.ConnReply) (err error) {
	if args == nil {
		err = ErrArgs
		log.Error("Connect() error(%v)", err)
		return
	}
	var (
		uid = r.auther.Auth(args.Token)
		seq int32
	)
	if seq, err = connect(uid, args.Server); err == nil {
		rep.Key = Encode(uid, seq)
	}
	return
}
Exemplo n.º 2
0
Arquivo: rpc.go Projeto: sf100/goim
// Connect auth and registe login
func (r *RPC) Connect(args *lproto.ConnArg, rep *lproto.ConnReply) (err error) {
	if args == nil {
		err = ErrArgs
		log.Error("Connect() error(%v)", err)
		return
	}
	// get userID from third implementation.
	// developer could implement "ThirdAuth" interface for decide how get userID
	userID := r.auther.Auth(args.Token)
	// notice router which connected
	c := getRouterClient(userID)
	arg := &rproto.ConnArg{UserId: userID, Server: args.Server}
	reply := &rproto.ConnReply{}
	if err = c.Call(routerServiceConnect, arg, reply); err != nil {
		log.Error("c.Call(\"%s\",\"%v\") error(%s)", routerServiceConnect, *arg, err)
		return
	}
	rep.Key = r.encode(userID, reply.Seq)
	return
}