func sendCommonLog(dir string, logType uint32, content string) {
	send_msg := protos.MarshalProtoMsg(&logProto.Log_CommonLogC2S{
		Dir:     protos.String(dir),
		Type:    protos.Uint32(logType),
		Content: protos.String(content),
		Time:    protos.Int64(time.Now().Unix()),
	})
	sendLogMsgToServer(send_msg)
}
//LoginServer用户上线
func SetClientSessionOnline(userSession *link.Session) {
	//发送用户上线消息到serverName
	protoMsg := &systemProto.System_ClientSessionOnlineC2S{
		SessionID: protos.Uint64(userSession.Id()),
		Network:   protos.String(userSession.Conn().RemoteAddr().Network()),
		Addr:      protos.String(userSession.Conn().RemoteAddr().String()),
	}
	send_msg := protos.MarshalProtoMsg(protoMsg)
	sendSystemMsg2("LoginServer", 0, send_msg)
}
//通知GameServer用户登录成功
func SetClientLoginSuccess(userName string, userID uint64, session *link.Session) {
	send_msg := protos.MarshalProtoMsg(&systemProto.System_ClientLoginSuccessC2S{
		UserID:       protos.Uint64(userID),
		UserName:     protos.String(userName),
		SessionID:    protos.Uint64(session.Id()),
		GameServerID: protos.Uint32(0),
		Network:      protos.String(session.Conn().RemoteAddr().Network()),
		Addr:         protos.String(session.Conn().RemoteAddr().String()),
	})
	sendSystemMsgToServer(send_msg)
}
Ejemplo n.º 4
0
//发送连接DB服务器
func sendConnectDBServer() {
	INFO(global.ServerName + " Connect DBServer ...")
	send_msg := protos.MarshalProtoMsg(&systemProto.System_ConnectDBServerC2S{
		ServerName: protos.String(global.ServerName),
	})
	protos.Send(dbClient, send_msg)
}
Ejemplo n.º 5
0
//用户登录
func userLogin(session *link.Session, protoMsg protos.ProtoMsg) {
	rev_msg := protoMsg.Body.(*dbProto.DB_User_LoginC2S)
	userName := rev_msg.GetName()

	//先从缓存中读取
	dbUser := redisProxy.GetDBUserByUserName(userName)
	if dbUser == nil {
		//从数据库中获取
		dbUser, _ = dao.GetUserByUserName(userName)
		//将数据缓存到Redis
		redisProxy.SetDBUser(dbUser)
	}

	//返回消息
	sendProtoMsg := &dbProto.DB_User_LoginS2C{}
	if dbUser != nil {
		sendProtoMsg.ID = protos.Uint64(dbUser.ID)
		sendProtoMsg.Name = protos.String(dbUser.Name)
	}
	send_msg := dbProto.MarshalProtoMsg(protoMsg.Identification, sendProtoMsg)
	sendDBMsgToClient(session, send_msg)

	//更新最后登录时间
	if dbUser != nil {
		dbUser.LastLoginTime = time.Now().Unix()
		redisProxy.UpdateUserLastLoginTime(dbUser)
	}
}
Ejemplo n.º 6
0
//发送连接LogServer
func sendConnectLogServer() {
	INFO(global.ServerName + " Connect LogServer ...")
	send_msg := protos.MarshalProtoMsg(&systemProto.System_ConnectLogServerC2S{
		ServerName: protos.String(global.ServerName),
	})
	sendSystemMsgToServer(send_msg)
}
Ejemplo n.º 7
0
//发送连接WorldServer
func sendConnectWorldServer() {
	INFO(global.ServerName + " Connect WorldServer ...")
	send_msg := protos.MarshalProtoMsg(&systemProto.System_ConnectWorldServerC2S{
		ServerName: protos.String(global.ServerName),
		ServerID:   protos.Uint32(global.ServerID),
	})
	SendSystemMsgToServer(send_msg)
}
Ejemplo n.º 8
0
//用户登录
func userLogin(session *link.Session, protoMsg dbProto.ProtoMsg) {
	rev_msg := protoMsg.Body.(*dbProto.DB_User_LoginC2S)

	sendProtoMsg := &dbProto.DB_User_LoginS2C{}
	dbUser, _ := module_db.GetUserByUserName(rev_msg.GetName())
	if dbUser != nil {
		redisProxy.SetDBUser(dbUser)

		sendProtoMsg.ID = protos.Uint64(dbUser.ID)
		sendProtoMsg.Name = protos.String(dbUser.Name)
	}

	send_msg := dbProto.MarshalProtoMsg(protoMsg.Identification, sendProtoMsg)
	sendDBMsgToClient(session, send_msg)
}
Ejemplo n.º 9
0
func SendGetUserInfoResult(errorCode int32, u *UserModel, session *link.Session) {
	if errorCode != 0 {
		SendErrorMsg(errorCode, session)
	} else {
		send_msg := MarshalProtoMsg(&GetUserInfoS2C{
			UserInfo: &Person{
				ID:        protos.Uint64(u.DBUser.ID),
				Name:      protos.String(u.DBUser.Name),
				Money:     protos.Int32(u.DBUser.Money),
				SessionID: protos.Uint64(session.Id()),
			},
		})
		Send(send_msg, session)
	}
}
Ejemplo n.º 10
0
//用户登录使用
func UserLogin(identification uint64, userName string) {
	msg := dbProto.MarshalProtoMsg(identification, &dbProto.DB_User_LoginC2S{
		Name: protos.String(userName),
	})
	sendDBMsgToServer(msg)
}
Ejemplo n.º 11
0
//发送连接DB服务器
func ConnectDBServer() {
	send_msg := systemProto.MarshalProtoMsg(&systemProto.System_ConnectDBServerC2S{
		ServerName: protos.String(global.ServerName),
	})
	systemProto.Send(send_msg, session)
}