Search in sources :

Example 1 with ServerConfig

use of com.code.server.login.config.ServerConfig in project summer by foxsugar.

the class LoginApplication method main.

public static void main(String[] args) {
    SpringApplication.run(LoginApplication.class, args);
    ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
    ServerManager.init();
    System.out.println(ServerManager.constant.toString());
    // 中心服务器有的职能
    if (serverConfig.getIsCenter() == 1) {
        // timer
        ThreadPool.execute(GameTimer.getInstance()::fire);
        CenterService.work();
        // rpc服务
        RpcManager.getInstance().startGameRpcServer();
        // 检测rpc
        RpcManager.getInstance().checkGameRpcServerWork();
    }
    // 俱乐部 逻辑
    ClubManager.getInstance().loadAll();
// MsgConsumer.startAConsumer("userService",0,new UserServiceConsumer());
// MsgConsumer.startAConsumer("userService",1,new UserServiceConsumer());
// MsgConsumer.startAConsumer("userService",2,new UserServiceConsumer());
// MsgConsumer.startAConsumer("userService",3,new UserServiceConsumer());
// MsgConsumer.startAConsumer("userService",4,new UserServiceConsumer());
}
Also used : ServerConfig(com.code.server.login.config.ServerConfig)

Example 2 with ServerConfig

use of com.code.server.login.config.ServerConfig in project summer by foxsugar.

the class LoginAction method createUser.

/**
 * 创建玩家
 *
 * @param account
 * @param password
 * @return
 */
private User createUser(String account, String password) {
    ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
    User newUser = new User();
    newUser.setAccount(account);
    newUser.setPassword(password);
    newUser.setOpenId("" + new IdWorker(serverConfig.getServerId(), 1).nextId());
    newUser.setUsername(decodeStr(account));
    newUser.setImage("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=253777390,947512827&fm=23&gp=0.jpg/96");
    newUser.setSex(1);
    newUser.setVip(0);
    newUser.setUuid("0");
    newUser.setMoney(getConstant().getInitMoney());
    newUser.setRegistDate(new Date());
    newUser.setLastLoginDate(new Date());
    return newUser;
}
Also used : ServerConfig(com.code.server.login.config.ServerConfig) User(com.code.server.db.model.User) IdWorker(com.code.server.util.IdWorker) Date(java.util.Date)

Aggregations

ServerConfig (com.code.server.login.config.ServerConfig)2 User (com.code.server.db.model.User)1 IdWorker (com.code.server.util.IdWorker)1 Date (java.util.Date)1