Example #1
0
File: rpc.go Project: 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
}
Example #2
0
File: rpc.go Project: 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
}