├── .gitignore
├── LICENSE
├── README.md
├── game-code-generate
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── snowcattle
│ │ └── game
│ │ ├── message
│ │ ├── logicgenerate
│ │ │ ├── enity
│ │ │ │ └── CommonPlayer.java
│ │ │ ├── http
│ │ │ │ └── room
│ │ │ │ │ └── client
│ │ │ │ │ └── HttpHeartClientMessage.java
│ │ │ └── tcp
│ │ │ │ └── room
│ │ │ │ └── client
│ │ │ │ └── RoomHeartClientMessage.java
│ │ └── protogenerate
│ │ │ ├── common
│ │ │ └── GameCommonMessageProBuf.java
│ │ │ ├── http
│ │ │ └── room
│ │ │ │ └── client
│ │ │ │ └── GameRoomHttpClientProBuf.java
│ │ │ └── tcp
│ │ │ └── room
│ │ │ └── client
│ │ │ └── GameRoomTCPClientProBuf.java
│ │ ├── service
│ │ └── net
│ │ │ ├── GameMessageCommandEnum.java
│ │ │ ├── GameMessageCommandFactory.java
│ │ │ └── GameMessageCommandIndex.java
│ │ └── template
│ │ ├── Converter.java
│ │ ├── MessageGenerator.java
│ │ ├── utils
│ │ ├── FileConentFactory.java
│ │ ├── FileContent.java
│ │ ├── FileContentFactoryImpl.java
│ │ └── FileUtils.java
│ │ └── xml
│ │ ├── FieldObject.java
│ │ ├── MacroObject.java
│ │ ├── MessageObject.java
│ │ └── XmlsLoader.java
│ └── resources
│ ├── config
│ ├── model
│ │ ├── http_client.xml
│ │ ├── macros.xml
│ │ └── room_client.xml
│ └── template
│ │ ├── macros.vm
│ │ ├── templatehttp.vm
│ │ └── templatetcp.vm
│ └── proto
│ ├── common.proto
│ ├── http_client.proto
│ ├── mac
│ └── back.txt
│ ├── tcproom-client.proto
│ └── windows
│ ├── back.txt
│ └── protoc.exe
├── game-common
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── snowcattle
│ └── game
│ ├── common
│ ├── IUpdatable.java
│ ├── ThreadNameFactory.java
│ ├── annotation
│ │ ├── AsyncOper.java
│ │ ├── AsyncThreadOper.java
│ │ ├── BlockingQueueType.java
│ │ ├── Comment.java
│ │ ├── GlobalEventListenerAnnotation.java
│ │ ├── IDictAnnotation.java
│ │ ├── MainThreadOper.java
│ │ ├── MessageCommandAnnotation.java
│ │ ├── NotThreadSafe.java
│ │ ├── RpcServiceAnnotation.java
│ │ ├── RpcServiceBoEnum.java
│ │ ├── SpecialEventListenerAnnotation.java
│ │ ├── SyncIoOper.java
│ │ ├── SyncOper.java
│ │ └── SysI18nString.java
│ ├── config
│ │ ├── AbstractGameConfigure.java
│ │ ├── Config.java
│ │ ├── ConfigUtil.java
│ │ ├── GameConfigurable.java
│ │ ├── GameDynamicPropertiesConfig.java
│ │ ├── GameServerConfig.java
│ │ ├── GameServerDiffConfig.java
│ │ ├── IGameConfig.java
│ │ ├── ServerConfig.java
│ │ ├── ZooKeeperConfig.java
│ │ └── script
│ │ │ ├── IScriptEngine.java
│ │ │ └── JSScriptManagerImpl.java
│ ├── constant
│ │ ├── CommonErrorLogInfo.java
│ │ ├── DynamicPropertiesEnum.java
│ │ ├── GlobalConstants.java
│ │ ├── Loggers.java
│ │ ├── ServiceName.java
│ │ └── SymbolConstants.java
│ ├── enums
│ │ ├── BOEnum.java
│ │ ├── DeliveryGuarantyOption.java
│ │ └── NetTypeEnum.java
│ ├── exception
│ │ ├── CacheConfigException.java
│ │ ├── CodecException.java
│ │ ├── ConfigException.java
│ │ ├── GameHandlerException.java
│ │ ├── GameInvalidLogicException.java
│ │ ├── IServerServiceException.java
│ │ ├── NetMessageException.java
│ │ ├── NoEnoughValueException.java
│ │ ├── StartUpException.java
│ │ ├── TransactionException.java
│ │ └── ValueLimitException.java
│ ├── scanner
│ │ ├── ClassScanner.java
│ │ └── PackageScaner.java
│ └── util
│ │ ├── AES.java
│ │ ├── ArgumentList.java
│ │ ├── ArrayUtils.java
│ │ ├── Assert.java
│ │ ├── BeanUtil.java
│ │ ├── ByteArrayBitSet.java
│ │ ├── CodecUtil.java
│ │ ├── CommonUtil.java
│ │ ├── ConactString.java
│ │ ├── DesEncrypter.java
│ │ ├── EnumUtil.java
│ │ ├── ErrorsUtil.java
│ │ ├── ExecutorUtil.java
│ │ ├── FileUtil.java
│ │ ├── FloatNumberPropertyArray.java
│ │ ├── GenericPropertyArray.java
│ │ ├── HttpUtil.java
│ │ ├── IKeyWordsFilter.java
│ │ ├── IOUtils.java
│ │ ├── IntNumberPropertyArray.java
│ │ ├── IntStringPair.java
│ │ ├── IsoUtils.java
│ │ ├── JVMMonitor.java
│ │ ├── JdomUtils.java
│ │ ├── JsScriptHelper.java
│ │ ├── JsonUtils.java
│ │ ├── KeyUtil.java
│ │ ├── KeyValuePair.java
│ │ ├── KeyWordsACFilter.java
│ │ ├── LRUHashMap.java
│ │ ├── MD5Util.java
│ │ ├── MathUtils.java
│ │ ├── MemUtils.java
│ │ ├── NumberUtil.java
│ │ ├── ObjectUtils.java
│ │ ├── PropertyArray.java
│ │ ├── PropertyRawSet.java
│ │ ├── RandomStringGenerator.java
│ │ ├── RandomUtil.java
│ │ ├── Range.java
│ │ ├── RegisterCode.java
│ │ ├── ResourcePathUtil.java
│ │ ├── ResourceUtil.java
│ │ ├── ShootUtils.java
│ │ ├── StringPropertyArray.java
│ │ ├── StringUtils.java
│ │ ├── ThreadPool.java
│ │ ├── ThreadUtil.java
│ │ ├── TimeMonitor.java
│ │ ├── TimeUtils.java
│ │ └── UniformRandomChooser.java
│ └── service
│ └── json
│ └── JsonSerializer.java
├── game-core
├── deploy
│ ├── build.sh
│ ├── config
│ │ └── launch.sh
│ └── dist.sh
├── pom.xml
├── proto
│ ├── common.proto
│ ├── http_client.proto
│ ├── mac
│ │ └── back.txt
│ ├── tcponline-server.proto
│ ├── tcponline.proto
│ ├── udponline.proto
│ └── windows
│ │ ├── back.txt
│ │ └── protoc.exe
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── snowcattle
│ │ │ │ └── game
│ │ │ │ ├── bootstrap
│ │ │ │ ├── GameServer.java
│ │ │ │ ├── GameServerRuntime.java
│ │ │ │ ├── GamerServerStartFinishedService.java
│ │ │ │ ├── ServerStatusLog.java
│ │ │ │ ├── ShutdownHook.java
│ │ │ │ └── manager
│ │ │ │ │ ├── AbstractGameManager.java
│ │ │ │ │ ├── AbstractLocalManager.java
│ │ │ │ │ ├── GlobalManager.java
│ │ │ │ │ ├── ILocalManager.java
│ │ │ │ │ ├── LocalMananger.java
│ │ │ │ │ ├── ServerServiceManager.java
│ │ │ │ │ └── spring
│ │ │ │ │ ├── AbstractSpringStart.java
│ │ │ │ │ ├── LocalSpringBeanManager.java
│ │ │ │ │ ├── LocalSpringServiceManager.java
│ │ │ │ │ └── LocalSpringServicerAfterManager.java
│ │ │ │ ├── logic
│ │ │ │ ├── net
│ │ │ │ │ ├── NetMessageProcessLogic.java
│ │ │ │ │ └── NetMessageTcpDispatchLogic.java
│ │ │ │ └── player
│ │ │ │ │ ├── GamePlayer.java
│ │ │ │ │ └── IPlayer.java
│ │ │ │ ├── message
│ │ │ │ ├── auto
│ │ │ │ │ ├── common
│ │ │ │ │ │ └── CommonMessageProBuf.java
│ │ │ │ │ ├── http
│ │ │ │ │ │ └── client
│ │ │ │ │ │ │ └── OnlineClientHttpProBuf.java
│ │ │ │ │ ├── tcp
│ │ │ │ │ │ └── online
│ │ │ │ │ │ │ ├── client
│ │ │ │ │ │ │ └── OnlineTCPClientProBuf.java
│ │ │ │ │ │ │ └── server
│ │ │ │ │ │ │ └── OnlineTCPServerProBuf.java
│ │ │ │ │ └── udp
│ │ │ │ │ │ └── online
│ │ │ │ │ │ └── OnlineUDPProBuf.java
│ │ │ │ ├── handler
│ │ │ │ │ ├── AbstractMessageHandler.java
│ │ │ │ │ ├── IMessageHandler.java
│ │ │ │ │ └── impl
│ │ │ │ │ │ ├── common
│ │ │ │ │ │ └── CommonHandlerImpl.java
│ │ │ │ │ │ ├── http
│ │ │ │ │ │ └── HttpHandlerImpl.java
│ │ │ │ │ │ └── online
│ │ │ │ │ │ ├── OnlineTcpHandlerImpl.java
│ │ │ │ │ │ └── OnlineUdpHandleImpl.java
│ │ │ │ └── logic
│ │ │ │ │ ├── http
│ │ │ │ │ └── client
│ │ │ │ │ │ └── OnlineHeartClientHttpMessage.java
│ │ │ │ │ ├── tcp
│ │ │ │ │ ├── common
│ │ │ │ │ │ ├── CommonErrorResponseServerMessage.java
│ │ │ │ │ │ └── CommonResponseServerMessage.java
│ │ │ │ │ └── online
│ │ │ │ │ │ ├── client
│ │ │ │ │ │ ├── OnlineHeartClientTcpMessage.java
│ │ │ │ │ │ └── OnlineLoginClientTcpMessage.java
│ │ │ │ │ │ └── server
│ │ │ │ │ │ └── OnlineLoginServerTcpMessage.java
│ │ │ │ │ └── udp
│ │ │ │ │ └── online
│ │ │ │ │ └── OnlineHeartClientUDPMessage.java
│ │ │ │ └── service
│ │ │ │ ├── IServerService.java
│ │ │ │ ├── IService.java
│ │ │ │ ├── Reloadable.java
│ │ │ │ ├── async
│ │ │ │ ├── AsyncCall.java
│ │ │ │ └── pool
│ │ │ │ │ ├── AsyncThreadPool.java
│ │ │ │ │ └── AsyncThreadService.java
│ │ │ │ ├── check
│ │ │ │ └── LifeCycleCheckService.java
│ │ │ │ ├── classes
│ │ │ │ └── loader
│ │ │ │ │ ├── DefaultClassLoader.java
│ │ │ │ │ ├── DynamicGameClassLoader.java
│ │ │ │ │ └── FileClassLoader.java
│ │ │ │ ├── config
│ │ │ │ └── GameServerConfigService.java
│ │ │ │ ├── dict
│ │ │ │ ├── DictArrayMaps.java
│ │ │ │ ├── DictCollectionEnum.java
│ │ │ │ ├── DictMap.java
│ │ │ │ ├── DictService.java
│ │ │ │ ├── IDict.java
│ │ │ │ └── IDictCollections.java
│ │ │ │ ├── event
│ │ │ │ ├── GameAsyncEventService.java
│ │ │ │ ├── SingleEventConstants.java
│ │ │ │ ├── impl
│ │ │ │ │ ├── SessionRegisterEvent.java
│ │ │ │ │ ├── SessionUnRegisterEvent.java
│ │ │ │ │ └── SingleRunEvent.java
│ │ │ │ └── listener
│ │ │ │ │ ├── SessionRegisterEventListener.java
│ │ │ │ │ ├── SessionUnRegisterEventListener.java
│ │ │ │ │ └── SingleRunEventListener.java
│ │ │ │ ├── limit
│ │ │ │ └── AtomicLimitNumber.java
│ │ │ │ ├── lookup
│ │ │ │ ├── AbstractLongLookUpService.java
│ │ │ │ ├── GamePlayerLoopUpService.java
│ │ │ │ ├── IChannleLookUpService.java
│ │ │ │ ├── ILongId.java
│ │ │ │ ├── ILongLookUpService.java
│ │ │ │ ├── NetTcpSessionLoopUpService.java
│ │ │ │ └── cache
│ │ │ │ │ └── EhcacheService.java
│ │ │ │ ├── message
│ │ │ │ ├── AbstractNetMessage.java
│ │ │ │ ├── AbstractNetProtoBufHttpMessage.java
│ │ │ │ ├── AbstractNetProtoBufMessage.java
│ │ │ │ ├── AbstractNetProtoBufTcpMessage.java
│ │ │ │ ├── AbstractNetProtoBufUdpMessage.java
│ │ │ │ ├── INetMessage.java
│ │ │ │ ├── NetHttpMessageHead.java
│ │ │ │ ├── NetMessageBody.java
│ │ │ │ ├── NetMessageHead.java
│ │ │ │ ├── NetProtoBufMessageBody.java
│ │ │ │ ├── NetUdpMessageHead.java
│ │ │ │ ├── command
│ │ │ │ │ ├── MessageCommand.java
│ │ │ │ │ ├── MessageCommandEnum.java
│ │ │ │ │ ├── MessageCommandFactory.java
│ │ │ │ │ └── MessageCommandIndex.java
│ │ │ │ ├── decoder
│ │ │ │ │ ├── INetProtoBufHttpMessageDecoderFactory.java
│ │ │ │ │ ├── INetProtoBufMessageDecoderFactory.java
│ │ │ │ │ ├── INetProtoBufTcpMessageDecoderFactory.java
│ │ │ │ │ ├── INetProtoBufUdpMessageDecoderFactory.java
│ │ │ │ │ ├── NetProtoBufHttpMessageDecoderFactory.java
│ │ │ │ │ ├── NetProtoBufMessageTCPDecoder.java
│ │ │ │ │ ├── NetProtoBufMessageUDPDecoder.java
│ │ │ │ │ ├── NetProtoBufTcpMessageDecoderFactory.java
│ │ │ │ │ ├── NetProtoBufUdpMessageDecoderFactory.java
│ │ │ │ │ └── RpcDecoder.java
│ │ │ │ ├── encoder
│ │ │ │ │ ├── INetProtoBufHttpMessageEncoderFactory.java
│ │ │ │ │ ├── INetProtoBufMessageEncoderFactory.java
│ │ │ │ │ ├── INetProtoBufTcpMessageEncoderFactory.java
│ │ │ │ │ ├── INetProtoBufUdpMessageEncoderFactory.java
│ │ │ │ │ ├── NetProtoBufHttpMessageEncoderFactory.java
│ │ │ │ │ ├── NetProtoBufMessageTCPEncoder.java
│ │ │ │ │ ├── NetProtoBufMessageUDPEncoder.java
│ │ │ │ │ ├── NetProtoBufTcpMessageEncoderFactory.java
│ │ │ │ │ ├── NetProtoBufUdpMessageEncoderFactory.java
│ │ │ │ │ └── RpcEncoder.java
│ │ │ │ ├── facade
│ │ │ │ │ ├── GameFacade.java
│ │ │ │ │ └── IFacade.java
│ │ │ │ ├── factory
│ │ │ │ │ ├── ITcpMessageFactory.java
│ │ │ │ │ ├── IUdpMessageFactory.java
│ │ │ │ │ └── TcpMessageFactory.java
│ │ │ │ ├── process
│ │ │ │ │ ├── INetProtoBufMessageProcess.java
│ │ │ │ │ └── NetProtoBufMessageProcess.java
│ │ │ │ └── registry
│ │ │ │ │ └── MessageRegistry.java
│ │ │ │ ├── net
│ │ │ │ ├── AbstractNettyServerService.java
│ │ │ │ ├── LocalNetService.java
│ │ │ │ ├── SdNetConfig.java
│ │ │ │ ├── broadcast
│ │ │ │ │ ├── GameTcpBroadCastService.java
│ │ │ │ │ └── IBroadCastService.java
│ │ │ │ ├── http
│ │ │ │ │ ├── AbstractNettyHttpServerService.java
│ │ │ │ │ ├── GameNetProtoMessageHttpServerChannelInitializer.java
│ │ │ │ │ ├── GameNettyHttpServerService.java
│ │ │ │ │ ├── NetHttpServerConfig.java
│ │ │ │ │ ├── SdHttpServerConfig.java
│ │ │ │ │ └── handler
│ │ │ │ │ │ ├── HttpServerHandler.java
│ │ │ │ │ │ └── async
│ │ │ │ │ │ └── AsyncNettyHttpHandlerService.java
│ │ │ │ ├── proxy
│ │ │ │ │ ├── NetProxyConfig.java
│ │ │ │ │ ├── ProxyRule.java
│ │ │ │ │ ├── ProxyTcpBackChannelInitializer.java
│ │ │ │ │ ├── ProxyTcpFrontedChannelInitializer.java
│ │ │ │ │ ├── ProxyTcpServerService.java
│ │ │ │ │ ├── SdProxyConfig.java
│ │ │ │ │ └── handler
│ │ │ │ │ │ ├── ProxyBackendHandler.java
│ │ │ │ │ │ └── ProxyFrontendHandler.java
│ │ │ │ ├── ssl
│ │ │ │ │ └── SSLService.java
│ │ │ │ ├── tcp
│ │ │ │ │ ├── AbstractNettyTcpServerService.java
│ │ │ │ │ ├── AbstractServerService.java
│ │ │ │ │ ├── GameNetProtoMessageTcpServerChannelInitializer.java
│ │ │ │ │ ├── GameNetRPCChannleInitializer.java
│ │ │ │ │ ├── GameNettyRPCService.java
│ │ │ │ │ ├── GameNettyTcpServerService.java
│ │ │ │ │ ├── MessageAttributeEnum.java
│ │ │ │ │ ├── RpcRequest.java
│ │ │ │ │ ├── RpcResponse.java
│ │ │ │ │ ├── handler
│ │ │ │ │ │ ├── AbstractGameNetMessageTcpServerHandler.java
│ │ │ │ │ │ ├── GameLoggingHandler.java
│ │ │ │ │ │ ├── GameNetMessageTcpServerHandler.java
│ │ │ │ │ │ ├── GameNetRPCServerHandler.java
│ │ │ │ │ │ └── async
│ │ │ │ │ │ │ ├── AsyncNettyGameNetMessageTcpServerHandler.java
│ │ │ │ │ │ │ └── AsyncNettyTcpHandlerService.java
│ │ │ │ │ ├── pipeline
│ │ │ │ │ │ ├── DefaultTcpServerPipeLine.java
│ │ │ │ │ │ ├── DefaultUdpServerPipeLine.java
│ │ │ │ │ │ ├── IServerPipeLine.java
│ │ │ │ │ │ └── factory
│ │ │ │ │ │ │ ├── DefaultTcpServerPipelineFactory.java
│ │ │ │ │ │ │ ├── DefaultUdpServerPipelineFactory.java
│ │ │ │ │ │ │ └── IServerPipelineFactory.java
│ │ │ │ │ ├── process
│ │ │ │ │ │ ├── GameTcpMessageProcessor.java
│ │ │ │ │ │ ├── GameUdpMessageOrderProcessor.java
│ │ │ │ │ │ ├── GameUdpMessageProcessor.java
│ │ │ │ │ │ ├── IMessageProcessor.java
│ │ │ │ │ │ ├── ITcpMessageProcessor.java
│ │ │ │ │ │ ├── QueueMessageExecutorProcessor.java
│ │ │ │ │ │ └── QueueTcpMessageExecutorProcessor.java
│ │ │ │ │ └── session
│ │ │ │ │ │ ├── INetMessageSender.java
│ │ │ │ │ │ ├── ISession.java
│ │ │ │ │ │ ├── NettySession.java
│ │ │ │ │ │ ├── NettyTcpNetMessageSender.java
│ │ │ │ │ │ ├── NettyTcpSession.java
│ │ │ │ │ │ ├── TcpNetState.java
│ │ │ │ │ │ ├── TcpNetStateUpdate.java
│ │ │ │ │ │ └── builder
│ │ │ │ │ │ ├── ISessionBuilder.java
│ │ │ │ │ │ ├── NettyTcpSessionBuilder.java
│ │ │ │ │ │ └── NettyUdpSessionBuilder.java
│ │ │ │ ├── udp
│ │ │ │ │ ├── AbstractNettyUdpServerService.java
│ │ │ │ │ ├── GameNetProtoMessageUdpServerChannelInitializer.java
│ │ │ │ │ ├── GameNettyUdpServerService.java
│ │ │ │ │ ├── NetUdpServerConfig.java
│ │ │ │ │ ├── SdUdpServerConfig.java
│ │ │ │ │ ├── handler
│ │ │ │ │ │ └── GameNetMessageUdpServerHandler.java
│ │ │ │ │ └── session
│ │ │ │ │ │ ├── NettyUdpNetMessageSender.java
│ │ │ │ │ │ └── NettyUdpSession.java
│ │ │ │ └── websocket
│ │ │ │ │ ├── AbstractNettyWebSocketServerService.java
│ │ │ │ │ ├── GameNetProtoMessageWebSocketServerChannelInitializer.java
│ │ │ │ │ ├── GameNettyWebSocketServerService.java
│ │ │ │ │ ├── NetWebSocketServerConfig.java
│ │ │ │ │ ├── SdWebSocketServerConfig.java
│ │ │ │ │ └── handler
│ │ │ │ │ ├── WebSocketServerHandler.java
│ │ │ │ │ └── async
│ │ │ │ │ ├── AsyncNettyWebSocketHandlerExecutorService.java
│ │ │ │ │ └── AsyncWebSocketFrameServerHandler.java
│ │ │ │ ├── rpc
│ │ │ │ ├── client
│ │ │ │ │ ├── AbstractRpcConnectManager.java
│ │ │ │ │ ├── AsyncRPCCallback.java
│ │ │ │ │ ├── RPCFuture.java
│ │ │ │ │ ├── RPCFutureService.java
│ │ │ │ │ ├── RpcClientConnectService.java
│ │ │ │ │ ├── RpcContextHolder.java
│ │ │ │ │ ├── RpcContextHolderObject.java
│ │ │ │ │ ├── RpcProxyService.java
│ │ │ │ │ ├── RpcRequestFactory.java
│ │ │ │ │ ├── ZookeeperRpcServiceDiscovery.java
│ │ │ │ │ ├── impl
│ │ │ │ │ │ ├── DbRpcConnnectMananger.java
│ │ │ │ │ │ ├── GameRpcConnecetMananger.java
│ │ │ │ │ │ └── WorldRpcConnectManager.java
│ │ │ │ │ ├── net
│ │ │ │ │ │ ├── RpcClient.java
│ │ │ │ │ │ ├── RpcClientConnection.java
│ │ │ │ │ │ ├── RpcClientHandler.java
│ │ │ │ │ │ ├── RpcClientInitializer.java
│ │ │ │ │ │ └── RpcServerConnectTask.java
│ │ │ │ │ └── proxy
│ │ │ │ │ │ ├── AsyncRpcProxy.java
│ │ │ │ │ │ ├── IAsyncRpcProxy.java
│ │ │ │ │ │ └── ObjectProxy.java
│ │ │ │ ├── serialize
│ │ │ │ │ ├── IRpcSerialize.java
│ │ │ │ │ └── protostuff
│ │ │ │ │ │ └── ProtostuffSerializeI.java
│ │ │ │ ├── server
│ │ │ │ │ ├── RemoteRpcHandlerService.java
│ │ │ │ │ ├── RpcHandlerThreadPool.java
│ │ │ │ │ ├── RpcMethodRegistry.java
│ │ │ │ │ ├── RpcNodeInfo.java
│ │ │ │ │ ├── RpcServerRegisterConfig.java
│ │ │ │ │ ├── RpcSystemConfig.java
│ │ │ │ │ ├── SdRpcServiceProvider.java
│ │ │ │ │ ├── SdServer.java
│ │ │ │ │ └── zookeeper
│ │ │ │ │ │ ├── ZooKeeperNodeBoEnum.java
│ │ │ │ │ │ ├── ZooKeeperNodeInfo.java
│ │ │ │ │ │ └── ZookeeperRpcServiceRegistry.java
│ │ │ │ └── service
│ │ │ │ │ ├── client
│ │ │ │ │ └── HelloService.java
│ │ │ │ │ └── server
│ │ │ │ │ └── HelloServiceImpl.java
│ │ │ │ ├── time
│ │ │ │ ├── SystemTimeService.java
│ │ │ │ ├── Time.java
│ │ │ │ └── TimeService.java
│ │ │ │ ├── update
│ │ │ │ └── NettyTcpSerssionUpdate.java
│ │ │ │ └── uuid
│ │ │ │ └── LongIdGenerator.java
│ │ └── resources
│ │ │ ├── bean
│ │ │ └── applicationContext.xml
│ │ │ ├── dynamic_config.properties
│ │ │ ├── game_server.cfg.js
│ │ │ ├── game_server_diff.cfg.js
│ │ │ ├── http-server.xml
│ │ │ ├── log4j.properties
│ │ │ ├── proxy-server.xml
│ │ │ ├── rpc-server-register.xml
│ │ │ ├── rpc-service-register.xml
│ │ │ ├── udp-server.xml
│ │ │ ├── websocket-server.xml
│ │ │ └── zookeeper.properties
│ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── snowcattle
│ │ │ └── game
│ │ │ ├── TestStartUp.java
│ │ │ ├── common
│ │ │ ├── codec
│ │ │ │ ├── client
│ │ │ │ │ ├── CodeCClient.java
│ │ │ │ │ └── CodeCStringClientChannelInitializer.java
│ │ │ │ └── server
│ │ │ │ │ ├── CodeServer.java
│ │ │ │ │ ├── CodeServerChannelInitializer.java
│ │ │ │ │ ├── CodeSocketServerHandler.java
│ │ │ │ │ ├── CodeSocketTwoServerHandler.java
│ │ │ │ │ └── TwoStringDecoder.java
│ │ │ ├── collections
│ │ │ │ └── ArrayTest.java
│ │ │ ├── dict
│ │ │ │ └── DictServiceTest.java
│ │ │ ├── ehcache
│ │ │ │ ├── Data.java
│ │ │ │ └── EacacheTest.java
│ │ │ ├── http
│ │ │ │ ├── HttpSnoopClient.java
│ │ │ │ ├── HttpSnoopClientHandler.java
│ │ │ │ ├── HttpSnoopClientInitializer.java
│ │ │ │ ├── HttpSnoopServer.java
│ │ │ │ ├── HttpSnoopServerHandler.java
│ │ │ │ └── HttpSnoopServerInitializer.java
│ │ │ ├── lock
│ │ │ │ └── ReadWriteLockTest.java
│ │ │ ├── lookuptest
│ │ │ │ └── lookup.java
│ │ │ ├── reflect
│ │ │ │ └── ReflectTest.java
│ │ │ ├── socket
│ │ │ │ ├── client
│ │ │ │ │ ├── ClientChannleInitializer.java
│ │ │ │ │ ├── EchoClient.java
│ │ │ │ │ ├── EchoClientHandler.java
│ │ │ │ │ ├── EchoStringSocketClientHandler.java
│ │ │ │ │ ├── LenghtStringClientHandler.java
│ │ │ │ │ ├── LengthStringClientChannleInitializer.java
│ │ │ │ │ ├── NetMessageClientChannelInitializer.java
│ │ │ │ │ ├── NetMessageClientHandler.java
│ │ │ │ │ └── StringClientChannelInitializer.java
│ │ │ │ ├── message
│ │ │ │ │ ├── INetMessageDecoderFactory.java
│ │ │ │ │ ├── INetMessageEncoderFactory.java
│ │ │ │ │ ├── NetMessageEncodeTest.java
│ │ │ │ │ ├── NetMessageEncoderFactory.java
│ │ │ │ │ ├── NetMessageTCPDecoder.java
│ │ │ │ │ ├── NetMessageTcpEncoder.java
│ │ │ │ │ └── NetTcpMessageDecoderFactory.java
│ │ │ │ └── server
│ │ │ │ │ ├── EchoServer.java
│ │ │ │ │ ├── EchoSocketServerHandler.java
│ │ │ │ │ ├── LenghtStringSocketServerHandler.java
│ │ │ │ │ ├── LengthStringDecoder.java
│ │ │ │ │ ├── LengthStringServerChannelInitializer.java
│ │ │ │ │ ├── NetMessageServerChannleInitializer.java
│ │ │ │ │ ├── NetMessageSocketServerHandler.java
│ │ │ │ │ ├── ServerChannelInitializer.java
│ │ │ │ │ └── StringServerChannelInitializer.java
│ │ │ ├── template
│ │ │ │ ├── ChileTemplate.java
│ │ │ │ ├── JdbcDaoSupport.java
│ │ │ │ ├── SuperTemplate.java
│ │ │ │ ├── Test.java
│ │ │ │ └── UserDao.java
│ │ │ ├── thread
│ │ │ │ ├── join
│ │ │ │ │ ├── ThreadTester.java
│ │ │ │ │ ├── ThreadTesterA.java
│ │ │ │ │ └── ThreadTesterB.java
│ │ │ │ ├── lock
│ │ │ │ │ └── ConditionTest.java
│ │ │ │ ├── pool
│ │ │ │ │ ├── QueuePoolExecutorTest.java
│ │ │ │ │ └── TestWorker.java
│ │ │ │ └── sync
│ │ │ │ │ ├── SingleLock.java
│ │ │ │ │ ├── TwinsLock.java
│ │ │ │ │ └── TwinsLockTest.java
│ │ │ ├── timer
│ │ │ │ ├── ScheduledThreadPoolExecutorTest.java
│ │ │ │ └── TimerTest.java
│ │ │ ├── udp
│ │ │ │ ├── client
│ │ │ │ │ ├── EchoJdkUdpClient.java
│ │ │ │ │ ├── EchoNettyUdpClient.java
│ │ │ │ │ ├── UdpClientChannelInitializer.java
│ │ │ │ │ ├── UdpHandler.java
│ │ │ │ │ ├── UdpProtoBufClientChannelInitializer.java
│ │ │ │ │ └── UdpProtoBufHandler.java
│ │ │ │ └── server
│ │ │ │ │ ├── EchoServer.java
│ │ │ │ │ ├── EchoServerHandler.java
│ │ │ │ │ ├── JavaUDPServer.java
│ │ │ │ │ ├── UdpChannelInitializer.java
│ │ │ │ │ └── UdpProtoBufServerChannelInitializer.java
│ │ │ ├── util
│ │ │ │ ├── DateFormatTest.java
│ │ │ │ ├── RandomStringGeneratorTest.java
│ │ │ │ └── concurrent
│ │ │ │ │ └── ConcurrentMapTest.java
│ │ │ ├── uuid
│ │ │ │ └── SnowflakeIdWorker.java
│ │ │ ├── websocket
│ │ │ │ ├── benchmarkserver
│ │ │ │ │ ├── WebSocketServer.java
│ │ │ │ │ ├── WebSocketServerBenchmarkPage.java
│ │ │ │ │ ├── WebSocketServerHandler.java
│ │ │ │ │ ├── WebSocketServerInitializer.java
│ │ │ │ │ └── package-info.java
│ │ │ │ ├── client
│ │ │ │ │ ├── WebSocketClient.java
│ │ │ │ │ └── WebSocketClientHandler.java
│ │ │ │ ├── server
│ │ │ │ │ ├── WebSocketFrameHandler.java
│ │ │ │ │ ├── WebSocketIndexPageHandler.java
│ │ │ │ │ ├── WebSocketServer.java
│ │ │ │ │ ├── WebSocketServerIndexPage.java
│ │ │ │ │ ├── WebSocketServerInitializer.java
│ │ │ │ │ └── package-info.java
│ │ │ │ └── websocket.html
│ │ │ └── zookeeper
│ │ │ │ ├── Carutor
│ │ │ │ ├── Carutor2.java
│ │ │ │ └── CuratorListenerUtils.java
│ │ │ │ └── zkclient
│ │ │ │ ├── Listener.java
│ │ │ │ ├── RetryConnect.java
│ │ │ │ ├── Test.java
│ │ │ │ └── ZookperTest.java
│ │ │ ├── extend
│ │ │ ├── GameManager.java
│ │ │ ├── GameServerEx.java
│ │ │ ├── GlobalManagerEx.java
│ │ │ ├── LocalSpringBeanGameManager.java
│ │ │ └── LocalSpringServiceGameManager.java
│ │ │ ├── jdbc
│ │ │ ├── Test.java
│ │ │ ├── entity
│ │ │ │ └── Order.java
│ │ │ ├── mapper
│ │ │ │ └── OrderMapper.java
│ │ │ └── service
│ │ │ │ ├── IOrderService.java
│ │ │ │ └── impl
│ │ │ │ └── OrderService.java
│ │ │ ├── net
│ │ │ └── client
│ │ │ │ ├── http
│ │ │ │ ├── GameHttpClient.java
│ │ │ │ ├── GameHttpClientHandler.java
│ │ │ │ └── GameHttpClientInitializer.java
│ │ │ │ ├── proxy
│ │ │ │ └── ProxyClient.java
│ │ │ │ ├── rpc
│ │ │ │ ├── HelloCallbackTest.java
│ │ │ │ ├── HelloServiceTest.java
│ │ │ │ ├── stresstest
│ │ │ │ │ └── HelloServiceStressTest.java
│ │ │ │ └── zookeeper
│ │ │ │ │ └── ZookeeperTest.java
│ │ │ │ ├── tcp
│ │ │ │ ├── GameClient.java
│ │ │ │ ├── GameClientChannleInitializer.java
│ │ │ │ └── GameClientHandler.java
│ │ │ │ ├── udp
│ │ │ │ └── GameNettyUdpClient.java
│ │ │ │ └── websocket
│ │ │ │ ├── GameWebSocketClient.java
│ │ │ │ └── GameWebSocketClientHandler.java
│ │ │ ├── service
│ │ │ └── dict
│ │ │ │ └── entity
│ │ │ │ ├── Bullet.java
│ │ │ │ └── RoleSkill.java
│ │ │ └── tps
│ │ │ └── rpc
│ │ │ ├── RpcTpsRunable.java
│ │ │ ├── mutil
│ │ │ └── MutilTest.java
│ │ │ └── single
│ │ │ └── SingleTest.java
│ │ └── resources
│ │ ├── back_up
│ │ └── log4j_back.properties
│ │ ├── bean
│ │ ├── applicationContext.xml
│ │ ├── db-applicationContext-redis.xml
│ │ └── db_applicationContext_datasource.xml
│ │ ├── db_jdbc.properties
│ │ ├── dict
│ │ ├── bullet
│ │ │ └── d_bullet.wg
│ │ ├── dict.wg
│ │ └── status
│ │ │ └── d_role_skill.wg
│ │ ├── dynamic_config.properties
│ │ ├── ehcache.xml
│ │ ├── game_server.cfg.js
│ │ ├── game_server_diff.cfg.js
│ │ ├── log4j.properties
│ │ ├── mybatis3
│ │ ├── mappers
│ │ │ └── orderMapper.xml
│ │ └── sqlMapConfig.xml
│ │ ├── rpc-server-register.xml
│ │ ├── rpc-service-register.xml
│ │ ├── sql
│ │ └── init.sql
│ │ ├── udp-server.xml
│ │ ├── websocket-server.xml
│ │ └── zookeeper.properties
└── tools
│ └── excelToCode
│ ├── config
│ └── config.py
│ └── python
│ ├── LICENSE
│ ├── README.md
│ ├── codegen
│ ├── __init__.py
│ ├── base_code_gen.py
│ └── java_code_gen.py
│ ├── doc
│ ├── how-to-config.md
│ ├── how-to-create-excel.md
│ └── images
│ │ ├── config-header@2x.png
│ │ ├── direct-header@2x.png
│ │ └── excel.png
│ ├── exporters
│ ├── __init__.py
│ ├── base_exporter.py
│ ├── config_exporter.py
│ ├── direct_exporter.py
│ └── mix_exporter.py
│ ├── gen_header_with_openpyxl.py
│ ├── gen_header_with_xlrd.py
│ ├── generate_code.py
│ ├── generate_header.py
│ ├── install_package.py
│ ├── load_configure.py
│ ├── logtool.py
│ ├── main.py
│ ├── numfmt.py
│ ├── openpyxl_extend.py
│ ├── parsers
│ ├── __init__.py
│ ├── base_parser.py
│ ├── config_parser.py
│ └── direct_parser.py
│ ├── postprocess
│ ├── __init__.py
│ ├── base_processor.py
│ ├── java_file_enum_processor.py
│ └── java_file_list_processor.py
│ ├── sample
│ ├── config.py
│ ├── excels
│ │ └── example.xlsx
│ ├── export.bat
│ ├── export.sh
│ └── export
│ │ ├── java
│ │ ├── code
│ │ │ ├── DictEnum.java
│ │ │ └── DictExample.java
│ │ └── data
│ │ │ ├── d_example.wg
│ │ │ └── dict.wg
│ │ └── xtemp
│ │ ├── configures.py
│ │ ├── example.py
│ │ └── files.py
│ ├── tps
│ ├── __init__.py
│ └── tp0.py
│ ├── util.py
│ ├── writers
│ ├── __init__.py
│ ├── base_writer.py
│ ├── java_writer.py
│ ├── json_writer.py
│ ├── lua_writer.py
│ └── py_writer.py
│ └── xlsconfig.py
├── game-db
├── README.md
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── snowcattle
│ │ │ └── game
│ │ │ └── db
│ │ │ ├── common
│ │ │ ├── DbServiceName.java
│ │ │ ├── GlobalConstants.java
│ │ │ ├── Loggers.java
│ │ │ ├── annotation
│ │ │ │ ├── AsyncEntityOperation.java
│ │ │ │ ├── DbMapper.java
│ │ │ │ ├── DbOperation.java
│ │ │ │ ├── EntitySave.java
│ │ │ │ ├── FieldSave.java
│ │ │ │ └── MethodSaveProxy.java
│ │ │ └── enums
│ │ │ │ └── DbOperationEnum.java
│ │ │ ├── entity
│ │ │ ├── AbstractEntity.java
│ │ │ ├── BaseLongIDEntity.java
│ │ │ ├── BaseStringIDEntity.java
│ │ │ ├── IEntity.java
│ │ │ └── ISoftDeleteEntity.java
│ │ │ ├── service
│ │ │ ├── async
│ │ │ │ ├── AsyncDbOperationCenter.java
│ │ │ │ ├── AsyncDbRegisterCenter.java
│ │ │ │ ├── AsyncEntityWrapper.java
│ │ │ │ ├── thread
│ │ │ │ │ ├── AsyncDbOperation.java
│ │ │ │ │ └── AsyncDbOperationMonitor.java
│ │ │ │ └── transaction
│ │ │ │ │ ├── entity
│ │ │ │ │ └── AsyncDBSaveTransactionEntity.java
│ │ │ │ │ └── factory
│ │ │ │ │ ├── DbGameTransactionCauseFactory.java
│ │ │ │ │ ├── DbGameTransactionEntityCauseFactory.java
│ │ │ │ │ ├── DbGameTransactionEntityFactory.java
│ │ │ │ │ └── DbGameTransactionKeyFactory.java
│ │ │ ├── common
│ │ │ │ ├── service
│ │ │ │ │ └── IDbService.java
│ │ │ │ └── uuid
│ │ │ │ │ ├── IUUIDService.java
│ │ │ │ │ └── SnowFlakeUUIDService.java
│ │ │ ├── config
│ │ │ │ └── DbConfig.java
│ │ │ ├── entity
│ │ │ │ ├── AsyncOperationRegistry.java
│ │ │ │ ├── EntityKeyShardingStrategyEnum.java
│ │ │ │ ├── EntityService.java
│ │ │ │ └── IEntityService.java
│ │ │ ├── jdbc
│ │ │ │ └── mapper
│ │ │ │ │ └── IDBMapper.java
│ │ │ ├── proxy
│ │ │ │ ├── EntityAysncServiceProxy.java
│ │ │ │ ├── EntityAysncServiceProxyFactory.java
│ │ │ │ ├── EntityProxy.java
│ │ │ │ ├── EntityProxyFactory.java
│ │ │ │ ├── EntityProxyWrapper.java
│ │ │ │ ├── EntityServiceProxy.java
│ │ │ │ └── EntityServiceProxyFactory.java
│ │ │ └── redis
│ │ │ │ ├── AsyncRedisKeyEnum.java
│ │ │ │ ├── AsyncSave.java
│ │ │ │ ├── RedisInterface.java
│ │ │ │ ├── RedisKeyEnum.java
│ │ │ │ ├── RedisListInterface.java
│ │ │ │ ├── RedisPageInterface.java
│ │ │ │ └── RedisService.java
│ │ │ ├── sharding
│ │ │ ├── AbstractShardingTable.java
│ │ │ ├── CustomerContextHolder.java
│ │ │ ├── DataSourceType.java
│ │ │ ├── DynamicDataSource.java
│ │ │ ├── EntityServiceShardingStrategy.java
│ │ │ └── ShardingTable.java
│ │ │ └── util
│ │ │ ├── EntityUtils.java
│ │ │ └── PageUtils.java
│ └── resources
│ │ ├── bean
│ │ ├── db-applicationContext-redis.xml
│ │ ├── db_applicationContext.xml
│ │ └── db_applicationContext_datasource.xml
│ │ ├── db_jdbc.properties
│ │ ├── log4j.properties
│ │ └── mybatis3
│ │ ├── mappers
│ │ └── orderMapper.xml
│ │ └── sqlMapConfig.xml
│ └── test
│ ├── java
│ └── com
│ │ └── snowcattle
│ │ └── game
│ │ └── db
│ │ └── service
│ │ ├── common
│ │ ├── aop
│ │ │ ├── AOPTest.java
│ │ │ ├── MyInterceptor.java
│ │ │ ├── Person.java
│ │ │ ├── PersonService.java
│ │ │ └── PersonServiceBean.java
│ │ ├── cache
│ │ │ ├── ObjectTest.java
│ │ │ └── redisTest.java
│ │ ├── cglib
│ │ │ ├── CglibProxy.java
│ │ │ ├── DoCGLib.java
│ │ │ └── SayHello.java
│ │ ├── entity
│ │ │ ├── ProxyTest.java
│ │ │ └── TestEntity.java
│ │ ├── fastjson
│ │ │ ├── Status.java
│ │ │ ├── StatusDeserializer.java
│ │ │ ├── Test.java
│ │ │ └── map
│ │ │ │ ├── Bar.java
│ │ │ │ ├── Foo.java
│ │ │ │ └── Test.java
│ │ ├── redis
│ │ │ ├── RedisPop.java
│ │ │ ├── RedisPush.java
│ │ │ └── Test.java
│ │ ├── uuid
│ │ │ ├── Snowflake.java
│ │ │ ├── SnowflakeIdWorker.java
│ │ │ └── SnowflakeTest.java
│ │ └── wrapper
│ │ │ └── TestWrapper.java
│ │ └── jdbc
│ │ ├── entity
│ │ ├── MoreOrder.java
│ │ ├── Order.java
│ │ └── Tocken.java
│ │ ├── mapper
│ │ ├── MoreOrderMapper.java
│ │ ├── OrderMapper.java
│ │ └── TockenMapper.java
│ │ ├── service
│ │ ├── entity
│ │ │ ├── IMoreOrderService.java
│ │ │ ├── IOrderService.java
│ │ │ ├── ITockenService.java
│ │ │ └── impl
│ │ │ │ ├── MoreOrderService.java
│ │ │ │ ├── OrderService.java
│ │ │ │ └── TockenService.java
│ │ └── operation
│ │ │ └── OrderServiceOperation.java
│ │ └── test
│ │ ├── TestConstants.java
│ │ ├── longEntity
│ │ ├── onetomore
│ │ │ ├── JdbcAsyncCacheTest.java
│ │ │ ├── JdbcCacheTest.java
│ │ │ └── JdbcTest.java
│ │ └── onetoone
│ │ │ ├── JdbcAsyncCacheTest.java
│ │ │ ├── JdbcCacheTest.java
│ │ │ └── JdbcTest.java
│ │ ├── stringEntity
│ │ └── onetoone
│ │ │ ├── JdbcAsyncCacheTest.java
│ │ │ ├── JdbcCacheTest.java
│ │ │ └── JdbcTest.java
│ │ └── tps
│ │ ├── mutilthread
│ │ ├── SaveRunable.java
│ │ ├── async
│ │ │ └── AsyncCacheTest.java
│ │ └── sync
│ │ │ ├── CacheTest.java
│ │ │ └── NoCacheTest.java
│ │ └── singleThread
│ │ ├── JdbcBatchOriginTest.java
│ │ └── JdbcTest.java
│ └── resources
│ ├── bean
│ ├── db-applicationContext-redis.xml
│ ├── db_applicationContext.xml
│ └── db_applicationContext_datasource.xml
│ ├── db_jdbc.properties
│ ├── log4j.properties
│ ├── mybatis3
│ ├── mappers
│ │ ├── moreOrderMapper.xml
│ │ ├── orderMapper.xml
│ │ └── tockenMapper.xml
│ └── sqlMapConfig.xml
│ └── sql
│ └── init.sql
├── game-executor
├── README.md
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── snowcattle
│ │ │ └── game
│ │ │ └── executor
│ │ │ ├── common
│ │ │ ├── UpdateExecutorEnum.java
│ │ │ └── utils
│ │ │ │ ├── CommonErrorInfo.java
│ │ │ │ ├── Constants.java
│ │ │ │ ├── Loggers.java
│ │ │ │ └── SystemPropertyUtil.java
│ │ │ ├── event
│ │ │ ├── AbstractEvent.java
│ │ │ ├── AbstractEventListener.java
│ │ │ ├── CycleEvent.java
│ │ │ ├── EventBus.java
│ │ │ ├── EventParam.java
│ │ │ ├── EventType.java
│ │ │ ├── SingleEvent.java
│ │ │ ├── common
│ │ │ │ ├── IEvent.java
│ │ │ │ ├── IEventBus.java
│ │ │ │ ├── IEventListener.java
│ │ │ │ └── constant
│ │ │ │ │ └── EventTypeEnum.java
│ │ │ ├── factory
│ │ │ │ └── CycleDisruptorEventFactory.java
│ │ │ ├── handler
│ │ │ │ └── CycleEventHandler.java
│ │ │ ├── impl
│ │ │ │ ├── event
│ │ │ │ │ ├── CreateEvent.java
│ │ │ │ │ ├── FinishEvent.java
│ │ │ │ │ ├── FinishedEvent.java
│ │ │ │ │ ├── ReadFinishEvent.java
│ │ │ │ │ ├── ReadyCreateEvent.java
│ │ │ │ │ └── UpdateEvent.java
│ │ │ │ └── listener
│ │ │ │ │ ├── CreateEventListener.java
│ │ │ │ │ ├── DispatchCreateEventListener.java
│ │ │ │ │ ├── DispatchFinishEventListener.java
│ │ │ │ │ ├── DispatchUpdateEventListener.java
│ │ │ │ │ ├── FinishEventListener.java
│ │ │ │ │ ├── ReadyCreateEventListener.java
│ │ │ │ │ ├── ReadyFinishEventListener.java
│ │ │ │ │ └── UpdateEventListener.java
│ │ │ └── service
│ │ │ │ ├── AsyncEventService.java
│ │ │ │ └── SingleEventWork.java
│ │ │ └── update
│ │ │ ├── cache
│ │ │ ├── UpdateEventCacheFactory.java
│ │ │ ├── UpdateEventCacheService.java
│ │ │ └── UpdateEventPoolFactory.java
│ │ │ ├── entity
│ │ │ ├── AbstractUpdate.java
│ │ │ ├── IUpdate.java
│ │ │ └── NullWeakUpUpdate.java
│ │ │ ├── pool
│ │ │ ├── DisruptorExecutorService.java
│ │ │ ├── IUpdateExecutor.java
│ │ │ ├── UpdateBindExecutorService.java
│ │ │ ├── UpdateExecutorService.java
│ │ │ └── excutor
│ │ │ │ ├── BindThreadUpdateExecutorService.java
│ │ │ │ ├── DelegatedExecutorService.java
│ │ │ │ ├── EventExecutor.java
│ │ │ │ ├── FinalizableDelegatedExecutorService.java
│ │ │ │ └── OrderedEventExecutor.java
│ │ │ ├── service
│ │ │ ├── NotifyTask.java
│ │ │ ├── UpdateNotifyService.java
│ │ │ └── UpdateService.java
│ │ │ └── thread
│ │ │ ├── dispatch
│ │ │ ├── BindNotifyDisptachThread.java
│ │ │ ├── DispatchThread.java
│ │ │ ├── DisruptorDispatchThread.java
│ │ │ └── LockSupportDisptachThread.java
│ │ │ ├── listener
│ │ │ └── LockSupportUpdateFutureListener.java
│ │ │ └── update
│ │ │ ├── LockSupportUpdateFuture.java
│ │ │ ├── LockSupportUpdateFutureThread.java
│ │ │ ├── UpdateThread.java
│ │ │ └── bind
│ │ │ ├── AbstractBindingUpdateThread.java
│ │ │ └── BindingUpdateThread.java
│ └── resources
│ │ └── log4j.properties
│ └── test
│ ├── java
│ └── com
│ │ └── snowcattle
│ │ └── game
│ │ └── executor
│ │ ├── TestLockSupport.java
│ │ ├── common
│ │ └── cache
│ │ │ └── CacheTest.java
│ │ ├── event
│ │ ├── aysnc
│ │ │ ├── AsyncEventServiceTest.java
│ │ │ ├── SingleRunEvent.java
│ │ │ ├── SingleRunEventListener.java
│ │ │ └── TestConstants.java
│ │ └── syns
│ │ │ └── SynsEventBusTest.java
│ │ └── update
│ │ ├── async
│ │ ├── AsyncUpdateBusTest.java
│ │ ├── IntegerUpdate.java
│ │ ├── TestCreateEvent.java
│ │ └── TestUpdateEvent.java
│ │ ├── asyncnotify
│ │ └── AsyncNotifyUpdateTest.java
│ │ └── disruptor
│ │ └── DisruptorTest.java
│ └── resources
│ └── log4j.properties
├── pom.xml
└── qrcode.png
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | *.tar.gz
3 | logs/
4 | .DS_Store
5 | .idea
6 | *.iml
7 | dist
8 | *.pyc
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | NettyGameServer
2 |
3 | - 使用netty4.X实现的手机游戏服务器,支持tcp,udp,http,websocket链接,采用protobuf自定义协议栈进行网络通信,支持rpc远程调用,使用mybatis3支持db存储分库分表,支持异步mysql存储,db保存时同步更新reids缓存。
4 | - 使用ExcelToCode工程,将excel数据生成java类和json数据字典,DictService直接读取json,减少数据字典部分代码。
5 | - 使用game-executor工程,增加游戏内的异步事件全局服务,支持事件sharding,均衡的异步执行事件逻辑
6 | - 使用netty的proxy模式,增加网关代理转发
7 | ## [Wiki/文档](https://github.com/jwpttcg66/NettyGameServer/wiki)
8 |
9 | ## 源码工具链接
10 | - [ExcelToCode 数据字典生成](https://github.com/youlanhai/ExcelToCode)
11 | - [GameShardingDb 游戏数据库](https://github.com/jwpttcg66/GameShardingDb)
12 | - [GameThreadPool 游戏常用线程池](https://github.com/jwpttcg66/GameThreadPool)
13 | - [game-executor 游戏常用循环调度执行器](https://github.com/jwpttcg66/game-executor)
14 | - [GameCodeGenerate 工具(包含新版本数据字典生成)](https://github.com/jwpttcg66/GameCodeGenerate)
15 | - [redis-game-transaction 事务](https://github.com/jwpttcg66/redis-game-transaction)
16 |
17 | #### 贡献源码&合作&交流
18 |
19 | - 作者qq 330258845
20 | - QQ群:310158485(已满) 513178622
21 |
22 | 
23 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/message/logicgenerate/enity/CommonPlayer.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.message.logicgenerate.enity;
2 |
3 | /**
4 | * 玩家
5 | *
6 | * @author CodeGenerator, don't modify this file please.
7 | */
8 |
9 | public class CommonPlayer {
10 | /**id*/
11 | private long id;
12 | /**name*/
13 | private String name;
14 |
15 | public void setId(long id){
16 | this.id = id;
17 | }
18 | public long getId(){
19 | return this.id;
20 | }
21 | public void setName(String name){
22 | this.name = name;
23 | }
24 | public String getName(){
25 | return this.name;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/service/net/GameMessageCommandIndex.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net;
2 |
3 | /**
4 | * Created by jiangwenping on 17/5/8.
5 | * 消息协议号索引
6 | */
7 | public final class GameMessageCommandIndex {
8 | public static final int ONLINE_HEART_CLIENT_TCP_MESSAGE = 1001;
9 | public static final int COMMON_RESPONSE_MESSAGE = 1002;
10 | public static final int COMMON_ERROR_RESPONSE_MESSAGE = 1003;
11 | public static final int HTTP_HEART_CLIENT_MESSAGE = 1004;
12 |
13 | private GameMessageCommandIndex() {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/template/utils/FileConentFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.template.utils;
2 |
3 | public interface FileConentFactory {
4 | FileContent create(String fileName, String content, String filePath);
5 | }
6 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/template/utils/FileContent.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.template.utils;
2 |
3 |
4 | public class FileContent {
5 | private String fileName;
6 | private String content;
7 | private String filePath;
8 |
9 | public String getFileName() {
10 | return fileName;
11 | }
12 | public void setFileName(String fileName) {
13 | this.fileName = fileName;
14 | }
15 | public String getContent() {
16 | return content;
17 | }
18 | public void setContent(String content) {
19 | this.content = content;
20 | }
21 | public String getFilePath() {
22 | return filePath;
23 | }
24 | public void setFilePath(String filePath) {
25 | this.filePath = filePath;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/template/utils/FileContentFactoryImpl.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.template.utils;
2 |
3 | public class FileContentFactoryImpl implements FileConentFactory {
4 | @Override
5 | public FileContent create(String fileName, String content, String filePath) {
6 | FileContent fileContent = new FileContent();
7 | fileContent.setFileName(fileName);
8 | fileContent.setContent(content);
9 | fileContent.setFilePath(filePath);
10 | return fileContent;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/java/com/snowcattle/game/template/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.template.utils;
2 |
3 |
4 | import java.io.File;
5 | import java.io.FileWriter;
6 | import java.io.IOException;
7 |
8 | public final class FileUtils{
9 | private FileUtils() {
10 | }
11 |
12 | public static void writeToFile(FileContent fileContent) throws IOException{
13 | File file = new File(fileContent.getFilePath()+fileContent.getFileName());
14 | if(!file.exists()){
15 | File folder = file.getParentFile();
16 | if(!folder.exists()){
17 | folder.mkdirs();
18 | }
19 | file.createNewFile();
20 | }else{
21 | file.delete();
22 | file.createNewFile();
23 | }
24 | System.out.println(file.getAbsolutePath());
25 | FileWriter writer = new FileWriter(file);
26 | writer.write(fileContent.getContent());
27 | writer.flush();
28 | writer.close();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/config/model/http_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/config/model/macros.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/config/model/room_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/common.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.protogenerate.common";
2 | option java_outer_classname = "GameCommonMessageProBuf";
3 |
4 | message CommonPlayerProBuf
5 | {
6 | required int64 playerId = 1;
7 | required string name = 2;
8 | }
9 |
10 | message CommonRoomPlayerProBuf
11 | {
12 | required int64 playerId = 1;
13 | required string name = 2;
14 | required int32 charaId = 3;
15 | }
16 |
17 | message Vector3ProBuf
18 | {
19 | required float x = 1;
20 | required float y = 2;
21 | required float z = 3;
22 | }
23 |
24 | message Vector4ProBuf
25 | {
26 | required float x = 1;
27 | required float y = 2;
28 | required float z = 3;
29 | required float w = 4;
30 | }
31 |
32 | message GameEndSinglePlayerProBuf{
33 | required int32 camp = 1;
34 | required int32 score = 2;
35 | }
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/http_client.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.protogenerate.http.room.client";
2 | option java_outer_classname = "GameRoomHttpClientProBuf";
3 |
4 | import "common.proto";
5 |
6 | /*心跳协议*/
7 | message RoomHeartHttpClientProBuf
8 | {
9 | }
10 |
11 |
12 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/mac/back.txt:
--------------------------------------------------------------------------------
1 | sudo protoc -I=/Users/jiangwenping/data/wolf-shoot-server-workspace/NettyGameServer/game-code-generate/src/main/resources/proto/ --java_out=/Users/jiangwenping/data/wolf-shoot-server-workspace/NettyGameServer/game-code-generate/src/main/java /Users/jiangwenping/data/wolf-shoot-server-workspace/NettyGameServer/game-code-generate/src/main/resources/proto/*.proto
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/tcproom-client.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.protogenerate.tcp.room.client";
2 | option java_outer_classname = "GameRoomTCPClientProBuf";
3 |
4 | import "common.proto";
5 |
6 | /*心跳协议*/
7 | message RoomHeartTCPClientProBuf
8 | {
9 | }
10 |
11 |
12 |
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/windows/back.txt:
--------------------------------------------------------------------------------
1 |
2 | C:\Users\B053-mac\Desktop\windws\server\proto\windows>protoc.exe -I C:\Users\B053-mac\Desktop\windws\server\proto --java_out=C:\Users\B053-mac\Desktop\windws\server\src C:\Users\B053-mac\Desktop\windws\server\proto\map.proto
3 |
4 | sudo protoc -I=/Users/b053-mac/data/IDEA-clover-200-workspace/game_server/proto/ --java_out=/Users/b053-mac/data/IDEA-clover-200-workspace/game_server/src /Users/b053-mac/data/IDEA-clover-200-workspace/game_server/proto/room.proto
5 |
6 | sudo protoc -I=/Users/jwp/data/wolfshoot-workspace/Server-Code/proto/ --java_out=/Users/jwp/data/wolfshoot-workspace/Server-Code/src/main/java /Users/jwp/data/wolfshoot-workspace/Server-Code/proto/common.proto
--------------------------------------------------------------------------------
/game-code-generate/src/main/resources/proto/windows/protoc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwpttcg66/NettyGameServer/6ef370c1116bdc617578d496d5d0a578da736084/game-code-generate/src/main/resources/proto/windows/protoc.exe
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/IUpdatable.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common;
2 |
3 | /**
4 | * Created by jwp on 2017/2/9.
5 | * 游戏的update接口
6 | */
7 | public interface IUpdatable {
8 | public boolean update();
9 | }
10 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/AsyncOper.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | *
11 | * 异步操作
12 | *
13 | *
14 | *
15 | */
16 | @Documented
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target(ElementType.METHOD)
19 | public @interface AsyncOper {
20 | }
21 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/AsyncThreadOper.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | *
11 | * 在异步线程中的操作
12 | *
13 | *
14 | * @see {@link MainThreadOper}
15 | *
16 | */
17 | @Documented
18 | @Retention(RetentionPolicy.RUNTIME)
19 | @Target(ElementType.METHOD)
20 | public @interface AsyncThreadOper {
21 | }
22 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/BlockingQueueType.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | /**
4 | * Created by jwp on 2017/3/8.
5 | */
6 | public enum BlockingQueueType {
7 | LINKED_BLOCKING_QUEUE("LinkedBlockingQueue"),
8 | ARRAY_BLOCKING_QUEUE("ArrayBlockingQueue"),
9 | SYNCHRONOUS_QUEUE("SynchronousQueue");
10 |
11 | private final String value;
12 |
13 | private BlockingQueueType(String value) {
14 | this.value = value;
15 | }
16 |
17 | public String getValue() {
18 | return value;
19 | }
20 |
21 | public static BlockingQueueType fromString(String value) {
22 | for (BlockingQueueType type : BlockingQueueType.values()) {
23 | if (type.getValue().equalsIgnoreCase(value.trim())) {
24 | return type;
25 | }
26 | }
27 |
28 | throw new IllegalArgumentException("Mismatched type with value=" + value);
29 | }
30 |
31 | public String toString() {
32 | return value;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/Comment.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * 注释
10 | *
11 | *
12 | *
13 | */
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target({ElementType.FIELD,ElementType.TYPE})
16 | public @interface Comment {
17 |
18 | /**
19 | * 注释内容
20 | */
21 | String content();
22 | }
23 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/GlobalEventListenerAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.lang.annotation.*;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | * 全局事件监听器注解
10 | */
11 | @Target(ElementType.TYPE)
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Component
14 | public @interface GlobalEventListenerAnnotation {
15 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/IDictAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.*;
4 |
5 | /**
6 | * Created by jiangwenping on 17/5/9.
7 | */
8 | @Documented
9 | @Retention(RetentionPolicy.RUNTIME)
10 | @Target(ElementType.METHOD)
11 | public @interface IDictAnnotation {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/MainThreadOper.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | *
11 | * 在主线程中的操作
12 | *
13 | *
14 | * @see {@link AsyncThreadOper}
15 | *
16 | */
17 | @Documented
18 | @Retention(RetentionPolicy.RUNTIME)
19 | @Target(ElementType.METHOD)
20 | public @interface MainThreadOper {
21 | }
22 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/MessageCommandAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 |
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Documented
10 | public @interface MessageCommandAnnotation {
11 | /**
12 | * @return
13 | */
14 | int command();
15 | }
16 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/NotThreadSafe.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * 线程不安全的实现
11 | *
12 | *
13 | *
14 | */
15 | @Documented
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target({ ElementType.METHOD, ElementType.TYPE })
18 | public @interface NotThreadSafe {
19 | }
20 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/RpcServiceAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Created by jwp on 2017/3/7.
12 | */
13 | @Target(ElementType.TYPE)
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Component
16 | public @interface RpcServiceAnnotation {
17 | Class> value();
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/RpcServiceBoEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import com.snowcattle.game.common.enums.BOEnum;
4 | import org.springframework.stereotype.Component;
5 |
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | /**
12 | * Created by jiangwenping on 17/4/26.
13 | */
14 | @Target(ElementType.TYPE)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Component
17 | public @interface RpcServiceBoEnum {
18 | BOEnum bo();
19 | }
20 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/SpecialEventListenerAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | *特殊事件监听器
12 | */
13 | @Target(ElementType.TYPE)
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Component
16 | public @interface SpecialEventListenerAnnotation {
17 | int listener();
18 | }
19 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/SyncIoOper.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * 同步操作
11 | *
12 | *
13 | *
14 | */
15 | @Documented
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target(ElementType.METHOD)
18 | public @interface SyncIoOper {
19 | }
20 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/SyncOper.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * 同步操作
11 | *
12 | *
13 | *
14 | */
15 | @Documented
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target(ElementType.METHOD)
18 | public @interface SyncOper {
19 | }
20 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/annotation/SysI18nString.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * 系统提示用多语言
10 | *
11 | *
12 | *
13 | */
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target(ElementType.FIELD)
16 | public @interface SysI18nString {
17 | /**
18 | * 多语言内容
19 | */
20 | String content();
21 |
22 | /**
23 | * 多语言参数注释
24 | */
25 | String comment() default "";
26 | }
27 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/config/Config.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.config;
2 |
3 | /**
4 | * 配置接口,用于提供系统配置内容
5 | *
6 | *
7 | */
8 | public interface Config {
9 | /**
10 | * 取得系统配置的版本号,该版本号不代表程序的真实版本号,只是声明的版本号
11 | */
12 | public abstract String getVersion();
13 |
14 | /**
15 | * 校验配置参数是否符合有效
16 | *
17 | * @exception IllegalArgumentException
18 | * 如果有参数配置错误,会抛出此异常
19 | */
20 | public abstract void validate();
21 |
22 | /**
23 | * 是否是调试模式
24 | *
25 | * @return
26 | */
27 | public boolean getIsDebug();
28 |
29 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/config/GameConfigurable.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.config;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/22.
5 | */
6 | public interface GameConfigurable {
7 | public String getProperty(String key, String defaultVal);
8 | public int getProperty(String key, int defaultVal);
9 | public boolean getProperty(String key, boolean defaultVal);
10 | public long getProperty(String key, long defaultVal);
11 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/config/GameDynamicPropertiesConfig.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.config;
2 |
3 |
4 | /**
5 | * @author jwp
6 | * 游戏动态配置
7 | */
8 | public class GameDynamicPropertiesConfig extends AbstractGameConfigure {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/config/IGameConfig.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.config;
2 |
3 | /**
4 | * @author b053-mac
5 | * 游戏配置
6 | */
7 | public interface IGameConfig {
8 |
9 | public void loadConfig(String filePath) throws Exception ;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/config/ZooKeeperConfig.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.config;
2 |
3 | /**
4 | * Created by jiangwenping on 17/3/30.
5 | * zookeeper配置服务
6 | */
7 | public class ZooKeeperConfig extends AbstractGameConfigure {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/constant/DynamicPropertiesEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.constant;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/22.
5 | * 动态属性
6 | */
7 | public enum DynamicPropertiesEnum {
8 | udp_message_tocken_check_flag,
9 | ;
10 | }
11 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/constant/SymbolConstants.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.constant;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/6/6.
5 | * 常用符号
6 | */
7 | public final class SymbolConstants {
8 | public static final String SEMICOLON=";";//分号
9 | public static final String SEMICOLON_REG=";|;";//分号
10 | public static final String COLON=":";//冒号
11 | public static final String COLON_REG=":|:";//冒号
12 | public static final String COMMA=",";
13 | public static final String COMMA_REG=",|,";
14 | public static final String XIEGANG_REG="/";
15 | public static final String SHUXIAN_REG="|";
16 | public static final String UNDERLINE_REG="_";
17 | public static final String JINGHAO_REG="#";
18 | public static final String AT_REG="@";
19 |
20 | private SymbolConstants() {
21 | }
22 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/enums/BOEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.enums;
2 |
3 | /**
4 | * @author C172
5 | * BO 服务器对象类型
6 | */
7 | public enum BOEnum {
8 |
9 | //网关
10 | PROXY(1),
11 | //世界
12 | WORLD(2),
13 | //游戏
14 | GAME(3),
15 | //db
16 | DB(4),
17 | ;
18 | private int boId;
19 |
20 | BOEnum(int boId) {
21 | this.boId = boId;
22 | }
23 |
24 | public int getBoId() {
25 | return boId;
26 | }
27 |
28 | public void setBoId(int boId) {
29 | this.boId = boId;
30 | }
31 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/enums/DeliveryGuarantyOption.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.enums;
2 |
3 | /**
4 | * Created by jwp on 2017/2/9.
5 | */
6 | public enum DeliveryGuarantyOption
7 | {
8 | /**
9 | * socket
10 | */
11 | RELIABLE(0),
12 | /**
13 | * udp
14 | */
15 | FAST(1);
16 | final int guaranty;
17 |
18 | DeliveryGuarantyOption(int guaranty)
19 | {
20 | this.guaranty = guaranty;
21 | }
22 |
23 | public int getGuaranty(){
24 | return guaranty;
25 | }
26 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/enums/NetTypeEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.enums;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/7/3.
5 | * 网络类型
6 | */
7 | public enum NetTypeEnum {
8 | HTTP,
9 | WEBSOCKET,
10 | TCP,
11 | UDP
12 | ;
13 | }
14 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/CacheConfigException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * 初始化cache
5 | *
6 | */
7 | public class CacheConfigException extends ConfigException {
8 |
9 | private static final long serialVersionUID = 1L;
10 |
11 | /**
12 | *
13 | * @param cacheName cache名称
14 | * @param errorInfo 错误
15 | */
16 | public CacheConfigException(String cacheName,
17 | String errorInfo) {
18 | super(String.format("[%s]%s", cacheName , errorInfo));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/CodecException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/8.
5 | */
6 | public class CodecException extends Exception {
7 | private static final long serialVersionUID = 1L;
8 |
9 | public CodecException(String name){
10 | super(name);
11 | }
12 | public CodecException(String name,Throwable t){
13 | super(name,t);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/ConfigException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * 适用于读取配置文件时产生的异常
5 | *
6 | */
7 | public class ConfigException extends RuntimeException {
8 | /** */
9 | private static final long serialVersionUID = 1L;
10 |
11 | public ConfigException(String msg) {
12 | super(msg);
13 | }
14 |
15 | public ConfigException(Exception e) {
16 | super(e);
17 | }
18 |
19 | public ConfigException(String msg, Exception e) {
20 | super(msg, e);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/GameHandlerException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * @author C172
5 | * 游戏处理错误
6 | */
7 | public class GameHandlerException extends Exception {
8 |
9 | private static final long serialVersionUID = 1L;
10 |
11 | public static final int COMMON_ERROR_STATE = 6000;
12 | public static final int COMMON_ERROR_MAX_CONNECT_TCP_SESSION_NUMBER = 6001;
13 | private int serial;
14 |
15 | public GameHandlerException(String name){
16 | super(name);
17 | }
18 | public GameHandlerException(String name,Throwable t){
19 | super(name,t);
20 | }
21 |
22 | public GameHandlerException(Exception e){
23 | super(e);
24 | }
25 |
26 | public GameHandlerException(Exception e, int serial){
27 | super(e);
28 | this.serial = serial;
29 | }
30 |
31 | public int getSerial() {
32 | return serial;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/GameInvalidLogicException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 |
4 | /**
5 | * 不合法的逻辑异常,用于程序的逻辑判断时处理不应该发生的情况。
6 | * 当非法情况发生时,应该可以清晰的记录异常的详细信息,所以构造函数必须提供详细的异常描述。
7 | */
8 | public final class GameInvalidLogicException extends Exception {
9 |
10 | /** */
11 | private static final long serialVersionUID = 552982663377276317L;
12 |
13 | /**
14 | * 构造一个不合法的逻辑异常。
15 | * @param message 异常的详细描述。
16 | */
17 | public GameInvalidLogicException(String message) {
18 | super(message);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/IServerServiceException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * 当服务处理失败的时候抛出该异常
5 | */
6 | public class IServerServiceException extends Exception {
7 |
8 | /**
9 | *
10 | */
11 | private static final long serialVersionUID = 1L;
12 |
13 | public IServerServiceException(String name){
14 | super(name);
15 | }
16 | public IServerServiceException(String name,Throwable t){
17 | super(name,t);
18 | }
19 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/NetMessageException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * Created by jwp on 2017/2/9.
5 | * 网络消息发送异常
6 | */
7 | public class NetMessageException extends Exception {
8 | private static final long serialVersionUID = 1L;
9 |
10 | public NetMessageException(String name){
11 | super(name);
12 | }
13 | public NetMessageException(String name, Throwable t){
14 | super(name,t);
15 | }
16 |
17 | public NetMessageException(Throwable t){
18 | super(t);
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/NoEnoughValueException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | public class NoEnoughValueException extends Exception {
4 |
5 | private static final long serialVersionUID = 8289893876272871973L;
6 |
7 | public NoEnoughValueException() {
8 | }
9 |
10 | public NoEnoughValueException(String message) {
11 | super(message);
12 | }
13 |
14 | public NoEnoughValueException(Throwable cause) {
15 | super(cause);
16 | }
17 |
18 | public NoEnoughValueException(String message, Throwable cause) {
19 | super(message, cause);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/StartUpException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | /**
4 | * Created by jiangwenping on 17/3/13.
5 | */
6 | public class StartUpException extends Exception{
7 | /**
8 | *
9 | */
10 | private static final long serialVersionUID = 1L;
11 |
12 | public StartUpException(String name){
13 | super(name);
14 | }
15 | public StartUpException(String name,Throwable t){
16 | super(name,t);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/TransactionException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | public class TransactionException extends RuntimeException {
4 |
5 | private static final long serialVersionUID = -7019206205634720119L;
6 |
7 | public TransactionException(){
8 | super();
9 | }
10 |
11 | public TransactionException(String msg){
12 | super(msg);
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/exception/ValueLimitException.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.exception;
2 |
3 | public class ValueLimitException extends Exception {
4 |
5 | private static final long serialVersionUID = 9133877059467765978L;
6 | }
7 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/scanner/ClassScanner.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.scanner;
2 |
3 |
4 | /**
5 | * @author C172
6 | * 消息扫描器
7 | */
8 | public class ClassScanner {
9 | public String[] scannerPackage(String namespace, String ext) throws Exception
10 | {
11 | String[] files = new PackageScaner().scanNamespaceFiles(namespace, ext, false, true);
12 | return files;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/BeanUtil.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 | import org.springframework.stereotype.Service;
7 |
8 | /**
9 | * Created by jiangwenping on 17/3/1.
10 | */
11 | @Service
12 | public class BeanUtil implements ApplicationContextAware {
13 |
14 | private static ApplicationContext ctx;
15 | @Override
16 | public void setApplicationContext(ApplicationContext arg0)throws BeansException {
17 | ctx = arg0;
18 | }
19 |
20 | public static Object getBean(String beanName) {
21 | if(ctx == null){
22 | throw new NullPointerException();
23 | }
24 | return ctx.getBean(beanName);
25 | }
26 |
27 |
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/IKeyWordsFilter.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | /**
4 | * 关键词过滤接口
5 | *
6 | *
7 | */
8 | public interface IKeyWordsFilter {
9 |
10 | /**
11 | * 使用关键字列表进行初始化
12 | *
13 | * @param keyWords
14 | * 关键字列表
15 | * @return 是否初始化成功,成功true,否则false
16 | */
17 | public abstract boolean initialize(String[] keyWords);
18 |
19 | /**
20 | * 过滤关键词
21 | *
22 | * @param s
23 | * 要被处理的字符串
24 | * @return 处理完毕的被过滤的字符串
25 | */
26 | public abstract String filt(String s);
27 |
28 | /**
29 | * 检测输入的消息是否有关键字
30 | *
31 | * @param inputMsg
32 | * 要检测的消息
33 | * @return 若有返回true,否则false
34 | */
35 | public abstract boolean contain(String inputMsg);
36 |
37 | }
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/IOUtils.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | import java.io.DataOutput;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 |
7 | public final class IOUtils {
8 | private IOUtils() {
9 | }
10 |
11 | public static void writeLengthString(DataOutput dout, String content,
12 | String charset) throws IOException {
13 | if (content == null) {
14 | content = "";
15 | }
16 | byte[] buf = content.getBytes(charset);
17 | dout.writeShort(buf.length);
18 | dout.write(buf);
19 | }
20 |
21 | /**
22 | * 关闭输入流,并忽略任何异常
23 | * @param in
24 | */
25 | public static void closeInputStream(InputStream in) {
26 | if (in != null) {
27 | try {
28 | in.close();
29 | } catch (Exception ignore) {
30 | }
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/IntStringPair.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | public class IntStringPair {
4 |
5 | private int key;
6 | private String value;
7 |
8 | public IntStringPair(int key,String value){
9 | this.key = key;
10 | this.value = value;
11 | }
12 |
13 | public int getKey() {
14 | return key;
15 | }
16 |
17 | public void setKey(int key) {
18 | this.key = key;
19 | }
20 |
21 | public String getValue() {
22 | return value;
23 | }
24 |
25 | public void setValue(String value) {
26 | this.value = value;
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/JsonUtils.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 |
4 | import com.alibaba.fastjson.JSON;
5 | import com.alibaba.fastjson.JSONException;
6 |
7 | import java.util.Map;
8 |
9 | /**
10 | * Created by jwp on 2017/2/28.
11 | */
12 | public final class JsonUtils {
13 |
14 | private JsonUtils() {
15 | }
16 |
17 | /**
18 | * 获取json字符串
19 | * @param map
20 | * @return
21 | */
22 | public static String getJsonStr(Map map){
23 | return JSON.toJSONString(map);
24 | }
25 |
26 | @SuppressWarnings("unchecked")
27 | public static Map getMapFromJson(String json) throws JSONException{
28 | return JSON.parseObject(json, Map.class);
29 | }
30 |
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/KeyUtil.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | import java.util.UUID;
4 |
5 | /**
6 | * 产生各种key的工具类
7 | *
8 | *
9 | *
10 | */
11 | public final class KeyUtil {
12 | /** Key的长度 */
13 | public static final int KEY_LEN = 32;
14 |
15 | private KeyUtil() {
16 | }
17 |
18 | /**
19 | * 产生一个UUID的Key
20 | *
21 | * @return
22 | */
23 | public static String UUIDKey() {
24 | return toShortKey(genUUIDKey());
25 | }
26 |
27 | /**
28 | * 生成UUID字符串
29 | *
30 | * @return
31 | */
32 | static String genUUIDKey() {
33 | return UUID.randomUUID().toString();
34 | }
35 |
36 | /**
37 | * 去掉UUID的字符串中的"-"符号,以取得较短的key值
38 | *
39 | * @param key
40 | * @return
41 | */
42 | static String toShortKey(String key) {
43 | return key.substring(0, 8) + key.substring(9, 13) + key.substring(14, 18) + key.subSequence(19, 23)
44 | + key.substring(24);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/MemUtils.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | public final class MemUtils {
4 |
5 | private MemUtils() {
6 | }
7 |
8 | public static long getUsedMemoryMB() {
9 | return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;
10 | }
11 |
12 | public static long getFreeMemoryMB() {
13 | return (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory()) / 1048576;
14 | }
15 |
16 | public static long getTotalMemoryMB() {
17 | return Runtime.getRuntime().maxMemory() / 1048576;
18 | }
19 |
20 | public static String memoryInfo() {
21 | long freeMem = getFreeMemoryMB();
22 | long totalMem = getTotalMemoryMB();
23 | return "Free memory " + freeMem + " Mb of " + totalMem + " Mb";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/Range.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 |
4 | public class Range> {
5 |
6 | private T min;
7 |
8 | private T max;
9 |
10 | private Range(){
11 | }
12 |
13 | public Range(T min, T max){
14 | this();
15 | setMin(min);
16 | setMax(max);
17 | }
18 |
19 | public T getMin() {
20 | return min;
21 | }
22 |
23 | public void setMin(T min) {
24 | this.min = min;
25 | }
26 |
27 | public T getMax() {
28 | return max;
29 | }
30 |
31 | public void setMax(T max) {
32 | this.max = max;
33 | }
34 |
35 |
36 | /**
37 | * 若value -> [min, max)返回true
38 | */
39 | public boolean contains(T value){
40 | return value.compareTo(min) >= 0 && value.compareTo(max) < 0;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/ResourcePathUtil.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | public final class ResourcePathUtil {
4 |
5 | private ResourcePathUtil() {
6 | }
7 |
8 | /**
9 | * 在指定资源路径找到给定资源文件,并返回资源文件的完整路径
10 | * 查找顺序如下
11 | * 1. 查找目标.jar的压缩包内路径
12 | * 2. 在程序的启动目录查找
13 | * @param resourceFileName
14 | * @return
15 | */
16 | public static String getRootPathWithoutSlash(String resourceFileName){
17 | try{
18 | String result = ResourcePathUtil.class.getResource('/' + resourceFileName).getPath();
19 | return result;
20 | }
21 | catch(Exception e){
22 | return System.getProperty("user.dir") + '/' + resourceFileName;
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/common/util/TimeMonitor.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.util;
2 |
3 | import com.snowcattle.game.common.constant.Loggers;
4 | import org.slf4j.Logger;
5 |
6 | /**
7 | * 时间监测器,用于调试过程
8 | *
9 | *
10 | */
11 | public class TimeMonitor {
12 | private final Logger logger = Loggers.timeMonitorLogger;
13 | private final boolean isDebug;
14 | public static final TimeMonitor DEBUG = new TimeMonitor(true);
15 |
16 | private long start = 0;
17 |
18 | public TimeMonitor(boolean isDebug) {
19 | this.isDebug = isDebug;
20 | }
21 |
22 | public void _s() {
23 | if (isDebug) {
24 | start = System.currentTimeMillis();
25 | }
26 | }
27 |
28 | public void _e(String p) {
29 | if (isDebug) {
30 | long e = System.currentTimeMillis();
31 | if(logger.isDebugEnabled()) {
32 | logger.debug(p + " time:" + (e - start) + "ms");
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/game-common/src/main/java/com/snowcattle/game/service/json/JsonSerializer.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.json;
2 |
3 | /**
4 | * 将对象中的数据转化成json格式字符串的转化器
5 | */
6 | public interface JsonSerializer {
7 |
8 | /**
9 | * 序列化
10 | * 将obj对象中的相关数据取出,串行化为json字符串
11 | * @return
12 | */
13 | String serialize();
14 |
15 | /**
16 | * 反序列化
17 | * 将json字符串里的信息抽取,反馈到对象中
18 | * @param pack
19 | */
20 | void deserialize(String pack);
21 | }
22 |
--------------------------------------------------------------------------------
/game-core/deploy/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #### config
3 | file_end=`date +_v1.0_%Y%m%d_%H%M`
4 | target_path=target
5 |
6 | #### buid
7 | cd ../
8 | mvn clean package -Dmaven.test.skip=true
9 |
10 | #### tar
11 | mkdir bin/temp
12 | mv ${target_path}/lib bin/temp/
13 | mv ${target_path}/resource bin/temp/
14 | cp bin/config/launch.sh bin/temp/
15 |
16 | cd bin/temp
17 | tar -zcvf netty_game_server${file_end}.tar.gz ./*
18 | mv netty_game_server${file_end}.tar.gz ../
19 | cd ..
20 | #### clean
21 | rm -rf temp
22 | cd ..
23 | mvn clean
24 |
--------------------------------------------------------------------------------
/game-core/deploy/dist.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | file_name=$1
4 | mkdir dist
5 | tar -zxvf ${file_name} -C dist
6 | cd dist
7 | sh launch.sh start
8 |
--------------------------------------------------------------------------------
/game-core/proto/common.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.auto.common";
2 | option java_outer_classname = "CommonMessageProBuf";
3 |
4 | message CommonResponseServerProBuf
5 | {
6 |
7 | }
8 |
9 |
10 | message CommonErrorResponseServerProBuf
11 | {
12 | required int32 state = 1;
13 | optional string arg = 2; //错误参数,格式:xx,xxx,xxxx
14 | }
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/game-core/proto/http_client.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.auto.http.client";
2 | option java_outer_classname = "OnlineClientHttpProBuf";
3 |
4 | import "common.proto";
5 |
6 | /*心跳协议*/
7 | message OnlineHeartClientHttpProBuf
8 | {
9 | required int32 id = 1;
10 | }
11 |
12 |
13 |
--------------------------------------------------------------------------------
/game-core/proto/tcponline-server.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.auto.tcp.online.server";
2 | option java_outer_classname = "OnlineTCPServerProBuf";
3 |
4 | message OnlineHeartTCPServerProBuf
5 | {
6 | required int64 playerId = 1;
7 | required int32 tocken = 2;
8 | }
9 |
10 |
11 |
--------------------------------------------------------------------------------
/game-core/proto/tcponline.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.auto.tcp.online.client";
2 | option java_outer_classname = "OnlineTCPClientProBuf";
3 |
4 | message OnlineHeartTCPClientProBuf
5 | {
6 | required int32 id = 1;
7 | }
8 |
9 | message OnlineLoginTCPClientProBuf
10 | {
11 | required int32 id = 1;
12 | }
13 |
14 |
15 |
--------------------------------------------------------------------------------
/game-core/proto/udponline.proto:
--------------------------------------------------------------------------------
1 | option java_package = "com.snowcattle.game.message.auto.udp.online";
2 | option java_outer_classname = "OnlineUDPProBuf";
3 |
4 | message OnlineHeartUDPProBuf
5 | {
6 | required int32 id = 1;
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/game-core/proto/windows/back.txt:
--------------------------------------------------------------------------------
1 |
2 | C:\Users\B053-mac\Desktop\windws\server\proto\windows>protoc.exe -I C:\Users\B053-mac\Desktop\windws\server\proto --java_out=C:\Users\B053-mac\Desktop\windws\server\src C:\Users\B053-mac\Desktop\windws\server\proto\map.proto
3 |
4 | sudo protoc -I=/Users/b053-mac/data/IDEA-clover-200-workspace/game_server/proto/ --java_out=/Users/b053-mac/data/IDEA-clover-200-workspace/game_server/src /Users/b053-mac/data/IDEA-clover-200-workspace/game_server/proto/room.proto
5 |
6 | sudo protoc -I=/Users/jwp/data/wolfshoot-workspace/Server-Code/proto/ --java_out=/Users/jwp/data/wolfshoot-workspace/Server-Code/src/main/java /Users/jwp/data/wolfshoot-workspace/Server-Code/proto/common.proto
--------------------------------------------------------------------------------
/game-core/proto/windows/protoc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwpttcg66/NettyGameServer/6ef370c1116bdc617578d496d5d0a578da736084/game-core/proto/windows/protoc.exe
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/bootstrap/ShutdownHook.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.bootstrap;
2 |
3 | import com.snowcattle.game.common.util.Assert;
4 | import org.springframework.context.support.ClassPathXmlApplicationContext;
5 |
6 | /**
7 | * Created by jiangwenping on 16/11/18.
8 | */
9 | public class ShutdownHook implements Runnable {
10 |
11 | ClassPathXmlApplicationContext classPathXmlApplicationContext;
12 |
13 | public ShutdownHook(ClassPathXmlApplicationContext classPathXmlApplicationContext) {
14 | Assert.notNull(classPathXmlApplicationContext, "The 'beanfactory' argument must not be null.");
15 | this.classPathXmlApplicationContext = classPathXmlApplicationContext;
16 | }
17 |
18 | public void run() { //重写Runnable中的run方法并在此销毁bean
19 | this.classPathXmlApplicationContext.destroy();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/bootstrap/manager/AbstractGameManager.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.bootstrap.manager;
2 |
3 | /**
4 | * Created by jwp on 2017/5/6.
5 | * 游戏拓展使用
6 | */
7 | public abstract class AbstractGameManager extends AbstractLocalManager{
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/bootstrap/manager/ILocalManager.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.bootstrap.manager;
2 |
3 | /**
4 | * Created by jwp on 2017/2/4.
5 | */
6 | public interface ILocalManager {
7 |
8 | public T get(Class clazz);
9 |
10 | public void create(Class clazz, Class inter) throws Exception;
11 |
12 | public void add(Object service, Class inter);
13 |
14 | public void shutdown();
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/logic/player/IPlayer.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.logic.player;
2 |
3 | import com.snowcattle.game.service.net.tcp.session.NettyTcpNetMessageSender;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/20.
7 | */
8 | public interface IPlayer {
9 | public long getPlayerId();
10 | public int getPlayerUdpTocken();
11 | public NettyTcpNetMessageSender getNettyTcpNetMessageSender();
12 | }
13 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/message/handler/IMessageHandler.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.message.handler;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/8.
7 | */
8 | public interface IMessageHandler {
9 | public Method getMessageHandler(int command);
10 | }
11 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/IServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service;
2 |
3 | /**
4 | * Created by jwp on 2017/2/4.
5 | * 服务器启动服务
6 | */
7 | public interface IServerService {
8 |
9 | public String getServiceId();
10 |
11 | public boolean initialize();
12 |
13 | public boolean startService() throws Exception;
14 | public boolean stopService() throws Exception;
15 |
16 | public void release();
17 |
18 | public byte getState();
19 | public boolean isRunning();
20 | }
21 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/IService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service;
2 |
3 | /**
4 | * Created by jwp on 2017/2/4.
5 | * 基础服务
6 | */
7 | public interface IService {
8 | public String getId();
9 | public void startup() throws Exception;
10 | public void shutdown() throws Exception;
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/Reloadable.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/7.
5 | * 可重新加载的对象接口
6 | */
7 | public interface Reloadable {
8 | public void reload() throws Exception ;
9 | }
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/async/AsyncCall.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.async;
2 |
3 | /**
4 | * Created by jiangwenping on 17/4/19.
5 | * 异步线程调用
6 | */
7 | public interface AsyncCall extends Runnable{
8 | public void call() throws Exception;
9 | }
10 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/async/pool/AsyncThreadPool.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.async.pool;
2 |
3 | import com.snowcattle.game.service.async.AsyncCall;
4 |
5 | import java.util.concurrent.Future;
6 |
7 | /**
8 | * Created by jiangwenping on 17/4/19.
9 | * 异步线程池
10 | */
11 | public interface AsyncThreadPool {
12 | public Future submit(AsyncCall asyncCall);
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/dict/DictCollectionEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.dict;
2 |
3 | /**
4 | * Created by jiangwenping on 17/5/9.
5 | * 数据字典集合类型
6 | */
7 | public enum DictCollectionEnum {
8 | /**
9 | * 唯一
10 | */
11 | unique,
12 | /**
13 | * 数组
14 | */
15 | array,
16 | ;
17 | }
18 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/dict/DictMap.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.dict;
2 |
3 | import java.util.Collection;
4 | import java.util.Map;
5 | import java.util.concurrent.ConcurrentHashMap;
6 |
7 | /**
8 | * Created by jiangwenping on 17/5/9.
9 | * map形数据字典,每个唯一
10 | */
11 | public class DictMap implements IDictCollections{
12 |
13 | //存放map形数据字典
14 | private final Map dictMap;
15 |
16 | public DictMap(){
17 | this.dictMap = new ConcurrentHashMap<>();
18 | }
19 |
20 | public void put(int id, IDict iDict){
21 | this.dictMap.put(id, iDict);
22 | }
23 |
24 | /**
25 | * 获取数据字典
26 | * @param id
27 | * @return
28 | */
29 | public IDict getDict(int id){
30 | return dictMap.get(id);
31 | }
32 |
33 | public Collection getAllDicts(){
34 | return dictMap.values();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/dict/IDict.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.dict;
2 |
3 | /**
4 | * Created by jiangwenping on 17/5/8.
5 | * 整个数据字典的子类
6 | */
7 | public interface IDict {
8 | public int getID();
9 | }
10 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/dict/IDictCollections.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.dict;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * Created by jiangwenping on 17/5/9.
7 | * 数据字典集合
8 | */
9 | public interface IDictCollections {
10 | /**
11 | * 获取所有数据字典
12 | * @return
13 | */
14 | public Collection getAllDicts();
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/SingleEventConstants.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event;
2 |
3 | import com.snowcattle.game.executor.event.EventType;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/5/22.
7 | */
8 | public final class SingleEventConstants {
9 | public static final EventType singleRunEventType = new EventType(1001);
10 | public static final EventType sessionRegister = new EventType(1002);
11 | public static final EventType sessionUnRegister = new EventType(1003);
12 |
13 | private SingleEventConstants() {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/impl/SessionRegisterEvent.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.impl;
2 |
3 | import com.snowcattle.game.executor.event.EventParam;
4 | import com.snowcattle.game.executor.event.SingleEvent;
5 | import com.snowcattle.game.service.event.SingleEventConstants;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | * 网络链接事件建立
10 | */
11 | public class SessionRegisterEvent extends SingleEvent{
12 |
13 | public SessionRegisterEvent(Long eventId, long shardingId, EventParam... parms) {
14 | super(SingleEventConstants.sessionRegister, eventId, shardingId, parms);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/impl/SessionUnRegisterEvent.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.impl;
2 |
3 | import com.snowcattle.game.executor.event.EventParam;
4 | import com.snowcattle.game.executor.event.SingleEvent;
5 | import com.snowcattle.game.service.event.SingleEventConstants;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | * 网络链接断开
10 | */
11 | public class SessionUnRegisterEvent extends SingleEvent {
12 | public SessionUnRegisterEvent( Long eventId, long shardingId, EventParam... parms) {
13 | super(SingleEventConstants.sessionUnRegister, eventId, shardingId, parms);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/impl/SingleRunEvent.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.impl;
2 |
3 | import com.snowcattle.game.executor.event.EventParam;
4 | import com.snowcattle.game.executor.event.EventType;
5 | import com.snowcattle.game.executor.event.SingleEvent;
6 |
7 | import java.io.Serializable;
8 |
9 | /**
10 | * Created by jiangwenping on 2017/5/22.
11 | */
12 | public class SingleRunEvent extends SingleEvent {
13 | public SingleRunEvent(EventType eventType, Serializable eventId, long shardingId, EventParam[] parms) {
14 | super(eventType, eventId, shardingId, parms);
15 | }
16 |
17 | private long runId;
18 |
19 | public long getRunId() {
20 | return runId;
21 | }
22 |
23 | public void setRunId(long runId) {
24 | this.runId = runId;
25 | }
26 |
27 | @Override
28 | public void call() {
29 | runId++;
30 |
31 | System.out.println("runId" + runId + " Id" + getShardingId() );
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/listener/SessionRegisterEventListener.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.listener;
2 |
3 | import com.snowcattle.game.common.annotation.GlobalEventListenerAnnotation;
4 | import com.snowcattle.game.executor.event.AbstractEventListener;
5 | import com.snowcattle.game.service.event.SingleEventConstants;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | */
10 | @GlobalEventListenerAnnotation
11 | public class SessionRegisterEventListener extends AbstractEventListener {
12 |
13 | @Override
14 | public void initEventType() {
15 | register(SingleEventConstants.sessionRegister);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/listener/SessionUnRegisterEventListener.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.listener;
2 |
3 | import com.snowcattle.game.common.annotation.GlobalEventListenerAnnotation;
4 | import com.snowcattle.game.executor.event.AbstractEventListener;
5 | import com.snowcattle.game.service.event.SingleEventConstants;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | */
10 | @GlobalEventListenerAnnotation
11 | public class SessionUnRegisterEventListener extends AbstractEventListener{
12 | @Override
13 | public void initEventType() {
14 | register(SingleEventConstants.sessionUnRegister);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/event/listener/SingleRunEventListener.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.event.listener;
2 |
3 | import com.snowcattle.game.common.annotation.GlobalEventListenerAnnotation;
4 | import com.snowcattle.game.executor.event.AbstractEventListener;
5 | import com.snowcattle.game.service.event.SingleEventConstants;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/5/22.
9 | *
10 | */
11 | @GlobalEventListenerAnnotation
12 | public class SingleRunEventListener extends AbstractEventListener {
13 | @Override
14 | public void initEventType() {
15 | register(SingleEventConstants.singleRunEventType);
16 | }
17 | }
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/limit/AtomicLimitNumber.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.limit;
2 |
3 | import java.util.concurrent.atomic.AtomicLong;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/6/28.
7 | * 原子计数器
8 | */
9 | public class AtomicLimitNumber {
10 |
11 | /**
12 | * 原子数量
13 | */
14 | private final AtomicLong atomicLong;
15 |
16 | public AtomicLimitNumber() {
17 | this.atomicLong = new AtomicLong();
18 | }
19 |
20 | public long increment(){
21 | return this.atomicLong.incrementAndGet();
22 | }
23 |
24 | public long decrement(){
25 | return this.atomicLong.decrementAndGet();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/lookup/GamePlayerLoopUpService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.lookup;
2 |
3 | import com.snowcattle.game.logic.player.GamePlayer;
4 | import org.springframework.stereotype.Service;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/21.
8 | * 玩家查找服务
9 | */
10 | @Service
11 | public class GamePlayerLoopUpService extends AbstractLongLookUpService{
12 |
13 | }
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/lookup/IChannleLookUpService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.lookup;
2 |
3 | import com.snowcattle.game.service.net.tcp.session.NettySession;
4 | import com.snowcattle.game.service.net.tcp.session.NettyTcpSession;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/13.
8 | */
9 | public interface IChannleLookUpService {
10 |
11 | /**
12 | * 查找
13 | * @param sessionId
14 | * @return
15 | */
16 | public NettySession lookup(long sessionId);
17 |
18 | /**
19 | * 增加
20 | * @param nettyTcpSession
21 | */
22 | public boolean addNettySession(NettyTcpSession nettyTcpSession);
23 |
24 | /**
25 | * 移除
26 | * @param nettyTcpSession
27 | * @return
28 | */
29 | public boolean removeNettySession(NettyTcpSession nettyTcpSession);
30 | }
31 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/lookup/ILongId.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.lookup;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/21.
5 | *
6 | */
7 | public interface ILongId {
8 | public long longId();
9 | }
10 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/lookup/ILongLookUpService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.lookup;
2 |
3 | /**
4 | * Created by jwp on 2017/2/10.
5 | * 提供查询服务
6 | */
7 | public interface ILongLookUpService {
8 |
9 | /**
10 | * 查找
11 | * @param id
12 | * @return
13 | */
14 | T lookup(long id);
15 |
16 | /**
17 | * 增加
18 | * @param t
19 | */
20 | void addT(T t);
21 |
22 | /**
23 | * 移除
24 | * @param t
25 | * @return
26 | */
27 | boolean removeT(T t);
28 |
29 | /**
30 | * 清除所有
31 | */
32 | void clear();
33 | }
34 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/AbstractNetProtoBufHttpMessage.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/9/28.
5 | */
6 | public abstract class AbstractNetProtoBufHttpMessage extends AbstractNetProtoBufMessage{
7 |
8 | public AbstractNetProtoBufHttpMessage(){
9 | super();
10 | setNetMessageHead(new NetHttpMessageHead());
11 | setNetMessageBody(new NetProtoBufMessageBody());
12 | initHeadCmd();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/AbstractNetProtoBufTcpMessage.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jwp on 2017/2/17.
5 | */
6 | public abstract class AbstractNetProtoBufTcpMessage extends AbstractNetProtoBufMessage{
7 |
8 | public AbstractNetProtoBufTcpMessage(){
9 | super();
10 | setNetMessageBody(new NetProtoBufMessageBody());
11 | initHeadCmd();
12 |
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/INetMessage.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jwp on 2017/2/17.
5 | * 基础协议
6 | */
7 | public interface INetMessage {
8 | public NetMessageHead getNetMessageHead();
9 | public NetMessageBody getNetMessageBody();
10 | }
11 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/NetHttpMessageHead.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/9/28.
5 | * http消息头部
6 | */
7 | public class NetHttpMessageHead extends NetMessageHead {
8 |
9 | private long playerId;
10 | private String tocken="";
11 |
12 | public long getPlayerId() {
13 | return playerId;
14 | }
15 |
16 | public void setPlayerId(long playerId) {
17 | this.playerId = playerId;
18 | }
19 |
20 | public String getTocken() {
21 | return tocken;
22 | }
23 |
24 | public void setTocken(String tocken) {
25 | this.tocken = tocken;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/NetMessageBody.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jwp on 2017/1/24.
5 | */
6 | public class NetMessageBody {
7 |
8 | /**
9 | * 存储数据
10 | */
11 | private byte[] bytes;
12 |
13 | public byte[] getBytes() {
14 | return bytes;
15 | }
16 |
17 | public void setBytes(byte[] bytes) {
18 | this.bytes = bytes;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/NetProtoBufMessageBody.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | import com.google.protobuf.AbstractMessage;
4 |
5 | /**
6 | * Created by jwp on 2017/1/26.
7 | * protobuf的messagebody实体
8 | */
9 | public class NetProtoBufMessageBody extends NetMessageBody {
10 |
11 | //将字节读取为protobuf的抽象对象
12 | private AbstractMessage abstractMessage;
13 |
14 | public AbstractMessage getAbstractMessage() {
15 | return abstractMessage;
16 | }
17 |
18 | public void setAbstractMessage(AbstractMessage abstractMessage) {
19 | this.abstractMessage = abstractMessage;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/NetUdpMessageHead.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/20.
5 | * udp需要加入playerId跟tocken
6 | */
7 | public class NetUdpMessageHead extends NetMessageHead{
8 | private long playerId;
9 | private int tocken;
10 |
11 | public long getPlayerId() {
12 | return playerId;
13 | }
14 |
15 | public void setPlayerId(long playerId) {
16 | this.playerId = playerId;
17 | }
18 |
19 | public int getTocken() {
20 | return tocken;
21 | }
22 |
23 | public void setTocken(int tocken) {
24 | this.tocken = tocken;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/command/MessageCommandFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.command;
2 |
3 | import org.springframework.stereotype.Service;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/5/10.
7 | */
8 | @Service
9 | public class MessageCommandFactory {
10 |
11 | public MessageCommand[] getAllCommands(){
12 | MessageCommandEnum[] set = MessageCommandEnum.values();
13 | MessageCommand[] messageCommands = new MessageCommand[set.length];
14 | for(int i = 0; i< set.length; i++){
15 | MessageCommandEnum messageCommandEnum = set[i];
16 | MessageCommand messageCommand = new MessageCommand(messageCommandEnum.command_id, messageCommandEnum.bo_id, messageCommandEnum.is_need_filter);
17 | messageCommands[i] = messageCommand;
18 | }
19 |
20 | return messageCommands;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/command/MessageCommandIndex.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.command;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/20.
5 | */
6 | public final class MessageCommandIndex {
7 | //
8 | public static final int ONLINE_HEART_CLIENT_TCP_MESSAGE = 1;
9 | public static final int COMMON_RESPONSE_MESSAGE = 2;
10 | public static final int COMMON_ERROR_RESPONSE_MESSAGE = 3;
11 | public static final int ONLINE_HEART_CLIENT_UDP_MESSAGE = 4;
12 | public static final int ONLINE_LOGIN_TCP_CLIENT_MESSAGE = 5;
13 | public static final int ONLINE_LOGIN_TCP_SERVER_MESSAGE = 6;
14 | public static final int ONLINE_HEART_HTTP_CLIENT_MESSAGE = 7;
15 | public static final int ONLINE_HEART_HTTP_SERVER_MESSAGE = 8;
16 |
17 | private MessageCommandIndex() {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/decoder/INetProtoBufHttpMessageDecoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.decoder;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/9/28.
5 | */
6 | public interface INetProtoBufHttpMessageDecoderFactory extends INetProtoBufMessageDecoderFactory{
7 | }
8 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/decoder/INetProtoBufMessageDecoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.decoder;
2 |
3 | import com.snowcattle.game.common.exception.CodecException;
4 | import com.snowcattle.game.service.message.AbstractNetProtoBufMessage;
5 | import io.netty.buffer.ByteBuf;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/9/28.
9 | */
10 | public interface INetProtoBufMessageDecoderFactory {
11 | public AbstractNetProtoBufMessage praseMessage(ByteBuf byteBuf) throws CodecException;
12 | }
13 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/decoder/INetProtoBufTcpMessageDecoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.decoder;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/3.
5 | */
6 | public interface INetProtoBufTcpMessageDecoderFactory extends INetProtoBufMessageDecoderFactory{
7 | }
8 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/decoder/INetProtoBufUdpMessageDecoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.decoder;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/20.
5 | */
6 | public interface INetProtoBufUdpMessageDecoderFactory extends INetProtoBufMessageDecoderFactory{
7 | }
8 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/encoder/INetProtoBufHttpMessageEncoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.encoder;
2 |
3 | /**
4 | * Created by jiangwenping on 2017/9/28.
5 | */
6 | public interface INetProtoBufHttpMessageEncoderFactory extends INetProtoBufMessageEncoderFactory{
7 | }
8 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/encoder/INetProtoBufMessageEncoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.encoder;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetProtoBufMessage;
4 | import io.netty.buffer.ByteBuf;
5 |
6 | /**
7 | * Created by jiangwenping on 2017/9/28.
8 | */
9 | public interface INetProtoBufMessageEncoderFactory {
10 | public ByteBuf createByteBuf(AbstractNetProtoBufMessage netMessage) throws Exception;
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/encoder/INetProtoBufTcpMessageEncoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.encoder;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/8.
5 | */
6 | public interface INetProtoBufTcpMessageEncoderFactory extends INetProtoBufMessageEncoderFactory{
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/encoder/INetProtoBufUdpMessageEncoderFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.encoder;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/20.
5 | */
6 | public interface INetProtoBufUdpMessageEncoderFactory extends INetProtoBufMessageEncoderFactory {
7 | }
8 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/facade/IFacade.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.facade;
2 |
3 | import com.snowcattle.game.common.exception.GameHandlerException;
4 | import com.snowcattle.game.service.message.AbstractNetMessage;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/8.
8 | */
9 | public interface IFacade {
10 | public AbstractNetMessage dispatch(AbstractNetMessage message) throws GameHandlerException;
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/factory/ITcpMessageFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.factory;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jwp on 2017/2/10.
7 | * 协议工厂
8 | */
9 | public interface ITcpMessageFactory {
10 | public AbstractNetMessage createCommonErrorResponseMessage(int serial, int state, String tip);
11 | public AbstractNetMessage createCommonErrorResponseMessage(int serial, int state);
12 | public AbstractNetMessage createCommonResponseMessage(int serial);
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/factory/IUdpMessageFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.factory;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetProtoBufUdpMessage;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/22.
7 | */
8 | public interface IUdpMessageFactory {
9 | public AbstractNetProtoBufUdpMessage createCommonErrorResponseMessage(int serial, int state);
10 | public AbstractNetProtoBufUdpMessage createCommonResponseMessage(int serial);
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/message/process/INetProtoBufMessageProcess.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.message.process;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jwp on 2017/2/9.
7 | */
8 | public interface INetProtoBufMessageProcess {
9 | public void processNetMessage();
10 | public void addNetMessage(AbstractNetMessage abstractNetMessage);
11 | public void close();
12 | }
13 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/AbstractNettyServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net;
2 |
3 | import com.snowcattle.game.service.net.tcp.AbstractServerService;
4 |
5 | import java.net.InetSocketAddress;
6 |
7 | /**
8 | * Created by jwp on 2017/2/4.
9 | * 抽象的tcp服务
10 | */
11 | public abstract class AbstractNettyServerService extends AbstractServerService {
12 |
13 | protected int serverPort;
14 | protected InetSocketAddress serverAddress;
15 |
16 |
17 | public AbstractNettyServerService(String serviceId, int serverPort) {
18 | super(serviceId);
19 | this.serverPort = serverPort;
20 | this.serverAddress = new InetSocketAddress(serverPort);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/broadcast/IBroadCastService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.broadcast;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/11/14.
7 | */
8 | public interface IBroadCastService {
9 | public void broadcastMessage(long sessionId, AbstractNetMessage NetMessage);
10 | }
11 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/http/GameNettyHttpServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.http;
2 |
3 | import io.netty.channel.ChannelInitializer;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/7/3.
7 | * http服务
8 | */
9 | public class GameNettyHttpServerService extends AbstractNettyHttpServerService{
10 | public GameNettyHttpServerService(String serviceId, int serverPort, String bossTreadName, String workThreadName, ChannelInitializer channelInitializer) {
11 | super(serviceId, serverPort, bossTreadName, workThreadName, channelInitializer);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/http/SdHttpServerConfig.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.http;
2 |
3 | import com.snowcattle.game.service.net.SdNetConfig;
4 | import org.jdom2.DataConversionException;
5 | import org.jdom2.Element;
6 |
7 | /**
8 | * Created by jiangwenping on 2017/7/3.
9 | */
10 | public class SdHttpServerConfig extends SdNetConfig{
11 |
12 | private int handleThreadSize;
13 |
14 | public void load(Element element) throws DataConversionException {
15 | super.load(element);
16 | handleThreadSize = Integer.valueOf(element.getChildTextTrim("handleThreadSize"));
17 | }
18 |
19 | public int getHandleThreadSize() {
20 | return handleThreadSize;
21 | }
22 |
23 | public void setHandleThreadSize(int handleThreadSize) {
24 | this.handleThreadSize = handleThreadSize;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/proxy/ProxyTcpServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.proxy;
2 |
3 | import com.snowcattle.game.service.net.tcp.AbstractNettyTcpServerService;
4 | import io.netty.channel.ChannelInitializer;
5 |
6 | /**
7 | * Created by jiangwenping on 2017/6/9.
8 | * 网络代理服务,用于支持网关
9 | */
10 | public class ProxyTcpServerService extends AbstractNettyTcpServerService{
11 |
12 | public ProxyTcpServerService(String serviceId, int serverPort, String bossTreadName, String workThreadName, ChannelInitializer channelInitializer) {
13 | super(serviceId, serverPort, bossTreadName, workThreadName, channelInitializer);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/GameNettyRPCService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp;
2 |
3 | import io.netty.channel.ChannelInitializer;
4 |
5 | /**
6 | * Created by jwp on 2017/3/7.
7 | * 增加rpc服务
8 | */
9 | public class GameNettyRPCService extends AbstractNettyTcpServerService{
10 |
11 | public GameNettyRPCService(String serviceId, int serverPort, String bossTreadName, String workThreadName, ChannelInitializer channelInitializer) {
12 | super(serviceId, serverPort, bossTreadName, workThreadName, channelInitializer);
13 | }
14 |
15 | @Override
16 | public boolean startService() throws Exception{
17 | boolean flag = super.startService();
18 | return flag;
19 | }
20 |
21 | @Override
22 | public boolean stopService() throws Exception{
23 | boolean flag = super.stopService();
24 | return flag;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/GameNettyTcpServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp;
2 |
3 | import io.netty.channel.ChannelInitializer;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/7.
7 | * 游戏里的的tcp服务
8 | *
9 | */
10 | public class GameNettyTcpServerService extends AbstractNettyTcpServerService {
11 |
12 | public GameNettyTcpServerService(String serviceId, int serverPort, String bossThreadName, String workThreadName, ChannelInitializer channelInitializer) {
13 | super(serviceId, serverPort, bossThreadName, workThreadName, channelInitializer);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/MessageAttributeEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp;
2 |
3 | /**
4 | * @author jwp
5 | * message附带参数
6 | */
7 | public enum MessageAttributeEnum {
8 |
9 | /**
10 | * tcp跟udp使用
11 | */
12 | DISPATCH_SESSION,
13 |
14 | /**
15 | * http使用
16 | */
17 | DISPATCH_HTTP_REQUEST,
18 |
19 | ;
20 | }
21 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/RpcResponse.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp;
2 |
3 | /**
4 | * Created by jwp on 2017/3/7.
5 | * rpc的返回对象
6 | */
7 | public class RpcResponse {
8 |
9 | private String requestId;
10 | private String error;
11 | private Object result;
12 |
13 | public boolean isError() {
14 | return error != null;
15 | }
16 |
17 | public String getRequestId() {
18 | return requestId;
19 | }
20 |
21 | public void setRequestId(String requestId) {
22 | this.requestId = requestId;
23 | }
24 |
25 | public String getError() {
26 | return error;
27 | }
28 |
29 | public void setError(String error) {
30 | this.error = error;
31 | }
32 |
33 | public Object getResult() {
34 | return result;
35 | }
36 |
37 | public void setResult(Object result) {
38 | this.result = result;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/pipeline/IServerPipeLine.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.pipeline;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 | import io.netty.channel.Channel;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/13.
8 | */
9 | public interface IServerPipeLine {
10 | public void dispatchAction(Channel channel, AbstractNetMessage abstractNetMessage);
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/pipeline/factory/DefaultTcpServerPipelineFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.pipeline.factory;
2 |
3 |
4 | import com.snowcattle.game.service.net.tcp.pipeline.DefaultTcpServerPipeLine;
5 | import com.snowcattle.game.service.net.tcp.pipeline.IServerPipeLine;
6 |
7 | /**
8 | * Created by jiangwenping on 17/2/14.
9 | */
10 | public class DefaultTcpServerPipelineFactory implements IServerPipelineFactory {
11 | @Override
12 | public IServerPipeLine createServerPipeLine() {
13 | return new DefaultTcpServerPipeLine();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/pipeline/factory/DefaultUdpServerPipelineFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.pipeline.factory;
2 |
3 | import com.snowcattle.game.service.net.tcp.pipeline.DefaultUdpServerPipeLine;
4 | import com.snowcattle.game.service.net.tcp.pipeline.IServerPipeLine;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/20.
8 | */
9 | public class DefaultUdpServerPipelineFactory implements IServerPipelineFactory{
10 | @Override
11 | public IServerPipeLine createServerPipeLine() {
12 | return new DefaultUdpServerPipeLine();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/pipeline/factory/IServerPipelineFactory.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.pipeline.factory;
2 |
3 |
4 | import com.snowcattle.game.service.net.tcp.pipeline.IServerPipeLine;
5 |
6 | /**
7 | * Created by jiangwenping on 17/2/14.
8 | */
9 | public interface IServerPipelineFactory {
10 | public IServerPipeLine createServerPipeLine();
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/process/IMessageProcessor.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.process;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/13.
7 | */
8 | public interface IMessageProcessor {
9 | /**
10 | * 启动消息处理器
11 | */
12 | public void start();
13 |
14 | /**
15 | * 停止消息处理器
16 | */
17 | public void stop();
18 |
19 | /**
20 | * 向消息队列投递消息
21 | *
22 | * @param msg
23 | */
24 | public void put(AbstractNetMessage msg);
25 |
26 | /**
27 | * 判断队列是否已经达到上限了
28 | * @return
29 | */
30 | public boolean isFull();
31 | }
32 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/process/ITcpMessageProcessor.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.process;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jiangwenping on 17/2/20.
7 | */
8 | public interface ITcpMessageProcessor extends IMessageProcessor{
9 |
10 | /**
11 | * 向消息队列投递消息
12 | * 直接投递到对象processor上面
13 | * @param msg
14 | */
15 | public void directPutTcpMessage(AbstractNetMessage msg);
16 | }
17 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/INetMessageSender.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session;
2 |
3 | import com.snowcattle.game.common.exception.NetMessageException;
4 | import com.snowcattle.game.service.message.AbstractNetMessage;
5 |
6 | /**
7 | * Created by jwp on 2017/2/9.
8 | * 消息处理器
9 | */
10 | public interface INetMessageSender {
11 | /**
12 | * 发送消息
13 | * @param abstractNetMessage
14 | * @return
15 | */
16 | boolean sendMessage(AbstractNetMessage abstractNetMessage) throws NetMessageException;
17 |
18 | /**
19 | * 关闭
20 | */
21 | void close() throws NetMessageException;
22 | }
23 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/ISession.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 |
5 | /**
6 | * Created by jwp on 2017/2/9.
7 | * 封装会话的业务逻辑
8 | */
9 | public interface ISession {
10 |
11 | /**
12 | * 判断当前会话是否处于连接状态
13 | *
14 | * @return
15 | */
16 | public boolean isConnected();
17 |
18 | /**
19 | * @param msg
20 | */
21 | public void write(AbstractNetMessage msg) throws Exception;
22 |
23 | /**
24 | *
25 | */
26 | public void close(boolean immediately);
27 |
28 | /**
29 | * 出现异常时是否关闭连接
30 | *
31 | * @return
32 | */
33 | public boolean closeOnException();
34 |
35 | public void write(byte[] msg) throws Exception;
36 |
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/TcpNetState.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session;
2 |
3 | /**
4 | * Created by jiangwenping on 17/2/21.
5 | */
6 | public enum TcpNetState {
7 | //链接状态
8 | CONNECTED,
9 | //掉线中
10 | DISCONNECTING,
11 | //掉线
12 | DISCONNECTED,
13 | //销毁
14 | DESTROY;
15 | }
16 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/builder/ISessionBuilder.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session.builder;
2 |
3 | import com.snowcattle.game.service.net.tcp.session.ISession;
4 | import io.netty.channel.Channel;
5 |
6 | /**
7 | * Created by jwp on 2017/2/9.
8 | */
9 | public interface ISessionBuilder {
10 | public ISession buildSession(Channel channel);
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/builder/NettyTcpSessionBuilder.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session.builder;
2 |
3 | import com.snowcattle.game.service.net.tcp.session.ISession;
4 | import com.snowcattle.game.service.net.tcp.session.NettyTcpSession;
5 | import io.netty.channel.Channel;
6 | import io.netty.util.AttributeKey;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | * Created by jwp on 2017/2/9.
11 | * 创造tcpsession 同时标记channel上的sessionId
12 | */
13 | @Service
14 | public class NettyTcpSessionBuilder implements ISessionBuilder {
15 |
16 | public static final AttributeKey channel_session_id = AttributeKey
17 | .valueOf("channel_session_id");
18 |
19 | @Override
20 | public ISession buildSession(Channel channel) {
21 | NettyTcpSession nettyTcpSession = new NettyTcpSession(channel);
22 | channel.attr(channel_session_id).set(nettyTcpSession.getSessionId());
23 | return nettyTcpSession ;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/tcp/session/builder/NettyUdpSessionBuilder.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.tcp.session.builder;
2 |
3 | import com.snowcattle.game.service.net.tcp.session.ISession;
4 | import com.snowcattle.game.service.net.udp.session.NettyUdpSession;
5 | import io.netty.channel.Channel;
6 | import org.springframework.stereotype.Service;
7 |
8 | /**
9 | * Created by jwp on 2017/2/17.
10 | * udp session的生成器
11 | */
12 | @Service
13 | public class NettyUdpSessionBuilder implements ISessionBuilder {
14 | @Override
15 | public ISession buildSession(Channel channel) {
16 | return new NettyUdpSession(channel);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/udp/GameNettyUdpServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.udp;
2 |
3 | import io.netty.channel.ChannelInitializer;
4 |
5 | /**
6 | * Created by jwp on 2017/2/17.
7 | * udp启动服务
8 | */
9 | public class GameNettyUdpServerService extends AbstractNettyUdpServerService {
10 | public GameNettyUdpServerService(String serviceId, int serverPort, String threadNameFactoryName, ChannelInitializer channelInitializer) {
11 | super(serviceId, serverPort, threadNameFactoryName, channelInitializer);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/udp/session/NettyUdpSession.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.udp.session;
2 |
3 | import com.snowcattle.game.service.message.AbstractNetMessage;
4 | import com.snowcattle.game.service.net.tcp.session.NettySession;
5 | import io.netty.channel.Channel;
6 |
7 | /**
8 | * Created by jwp on 2017/2/16.
9 | * netty的udp session
10 | */
11 | public class NettyUdpSession extends NettySession {
12 |
13 | private final NettyUdpNetMessageSender nettyUdpNetMessageSender;
14 | public NettyUdpSession(Channel channel) {
15 | super(channel);
16 | this.nettyUdpNetMessageSender = new NettyUdpNetMessageSender(this);
17 | }
18 |
19 | public void write(AbstractNetMessage msg) throws Exception {
20 | if (msg != null) {
21 | channel.writeAndFlush(msg).sync();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/net/websocket/GameNettyWebSocketServerService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.net.websocket;
2 |
3 | import io.netty.channel.ChannelInitializer;
4 |
5 | /**
6 | * Created by jiangwenping on 2017/11/8.
7 | * websocket服务
8 | */
9 | public class GameNettyWebSocketServerService extends AbstractNettyWebSocketServerService{
10 | public GameNettyWebSocketServerService(String serviceId, int serverPort, String bossTreadName, String workThreadName, ChannelInitializer channelInitializer) {
11 | super(serviceId, serverPort, bossTreadName, workThreadName, channelInitializer);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/AsyncRPCCallback.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client;
2 |
3 | /**
4 | */
5 | public interface AsyncRPCCallback {
6 |
7 | void success(Object result);
8 |
9 | void fail(Exception e);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/RpcContextHolder.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client;
2 |
3 | /**
4 | * Created by jiangwenping on 17/3/13.
5 | * rpc 服务器列表选择
6 | */
7 | public final class RpcContextHolder {
8 |
9 | private static final ThreadLocal contextHolder = new ThreadLocal();
10 |
11 | private RpcContextHolder() {
12 | }
13 |
14 | public static RpcContextHolderObject getContext() {
15 | return contextHolder.get();
16 | }
17 | /**
18 | * 通过字符串选择数据源
19 | * @param rpcContextHolderObject
20 | */
21 | public static void setContextHolder(RpcContextHolderObject rpcContextHolderObject) {
22 | contextHolder.set(rpcContextHolderObject);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/RpcContextHolderObject.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client;
2 |
3 | import com.snowcattle.game.common.enums.BOEnum;
4 |
5 | /**
6 | * Created by jiangwenping on 17/3/15.
7 | */
8 | public class RpcContextHolderObject {
9 |
10 | private BOEnum boEnum;
11 | private int ServerId;
12 |
13 | public RpcContextHolderObject(BOEnum boEnum, int serverId) {
14 | this.boEnum = boEnum;
15 | ServerId = serverId;
16 | }
17 |
18 | public BOEnum getBoEnum() {
19 | return boEnum;
20 | }
21 |
22 | public void setBoEnum(BOEnum boEnum) {
23 | this.boEnum = boEnum;
24 | }
25 |
26 | public int getServerId() {
27 | return ServerId;
28 | }
29 |
30 | public void setServerId(int serverId) {
31 | ServerId = serverId;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/impl/DbRpcConnnectMananger.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client.impl;
2 |
3 | import com.snowcattle.game.service.rpc.client.AbstractRpcConnectManager;
4 | import org.springframework.stereotype.Service;
5 |
6 | /**
7 | * Created by jiangwenping on 17/3/15.
8 | * db rpc
9 | */
10 | @Service
11 | public class DbRpcConnnectMananger extends AbstractRpcConnectManager {
12 | }
13 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/impl/GameRpcConnecetMananger.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client.impl;
2 |
3 | import com.snowcattle.game.service.rpc.client.AbstractRpcConnectManager;
4 | import org.springframework.stereotype.Service;
5 |
6 | /**
7 | * Created by jiangwenping on 17/3/15.
8 | * 游戏rpc manger
9 | */
10 | @Service
11 | public class GameRpcConnecetMananger extends AbstractRpcConnectManager {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/impl/WorldRpcConnectManager.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client.impl;
2 |
3 | import com.snowcattle.game.service.rpc.client.AbstractRpcConnectManager;
4 | import org.springframework.stereotype.Service;
5 |
6 | /**
7 | * Created by jiangwenping on 17/3/15.
8 | * 世界rpc
9 | */
10 | @Service
11 | public class WorldRpcConnectManager extends AbstractRpcConnectManager {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/client/proxy/IAsyncRpcProxy.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.client.proxy;
2 |
3 | import com.snowcattle.game.service.rpc.client.RPCFuture;
4 |
5 | /**
6 | * Created by jwp on 2017/3/9.
7 | */
8 | public interface IAsyncRpcProxy {
9 | public RPCFuture call(String funcName, Object... args);
10 | }
11 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/serialize/IRpcSerialize.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.serialize;
2 |
3 | /**
4 | * Created by jwp on 2017/3/8.
5 | * rpc对象序列化
6 | */
7 | public interface IRpcSerialize {
8 |
9 | public byte[] serialize(T obj);
10 |
11 | public T deserialize(byte[] data, Class cls);
12 | }
13 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/server/RpcNodeInfo.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.server;
2 |
3 | /**
4 | * Created by jiangwenping on 17/4/1.
5 | */
6 | public class RpcNodeInfo {
7 |
8 | /**
9 | * 服务器id
10 | */
11 | private String serverId;
12 | private String host;
13 | private String port;
14 |
15 | public String getServerId() {
16 | return serverId;
17 | }
18 |
19 | public void setServerId(String serverId) {
20 | this.serverId = serverId;
21 | }
22 |
23 | public String getHost() {
24 | return host;
25 | }
26 |
27 | public void setHost(String host) {
28 | this.host = host;
29 | }
30 |
31 | public String getPort() {
32 | return port;
33 | }
34 |
35 | public void setPort(String port) {
36 | this.port = port;
37 | }
38 |
39 | public int getIntPort(){
40 | return Integer.parseInt(port);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/server/RpcSystemConfig.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.server;
2 |
3 | /**
4 | * Created by jwp on 2017/3/8.
5 | */
6 | public final class RpcSystemConfig {
7 | public static final String SystemPropertyThreadPoolRejectedPolicyAttr = "com.newlandframework.rpc.parallel.rejected.policy";
8 | public static final String SystemPropertyThreadPoolQueueNameAttr = "com.newlandframework.rpc.parallel.queue";
9 | public static final int PARALLEL = Math.max(2, Runtime.getRuntime().availableProcessors());
10 |
11 | private static boolean monitorServerSupport = false;
12 |
13 | private RpcSystemConfig() {
14 | }
15 |
16 | public static boolean isMonitorServerSupport() {
17 | return monitorServerSupport;
18 | }
19 |
20 | public static void setMonitorServerSupport(boolean jmxSupport) {
21 | monitorServerSupport = jmxSupport;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/server/zookeeper/ZooKeeperNodeBoEnum.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.server.zookeeper;
2 |
3 | import com.snowcattle.game.common.enums.BOEnum;
4 |
5 | /**
6 | * Created by jiangwenping on 17/3/31.
7 | */
8 | public enum ZooKeeperNodeBoEnum {
9 | WORLD(BOEnum.WORLD, "/world_registry_adress"),
10 | GAME(BOEnum.GAME, "/game_registry_adress"),
11 | DB(BOEnum.DB, "/db_registry_adress"),
12 | ;
13 | private BOEnum boEnum;
14 | private String rootPath;
15 |
16 | ZooKeeperNodeBoEnum(BOEnum boEnum, String rootPath) {
17 | this.boEnum = boEnum;
18 | this.rootPath = rootPath;
19 | }
20 |
21 | public BOEnum getBoEnum() {
22 | return boEnum;
23 | }
24 |
25 | public void setBoEnum(BOEnum boEnum) {
26 | this.boEnum = boEnum;
27 | }
28 |
29 | public String getRootPath() {
30 | return rootPath;
31 | }
32 |
33 | public void setRootPath(String rootPath) {
34 | this.rootPath = rootPath;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/service/client/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.service.client;
2 |
3 | /**
4 | * Created by jwp on 2017/3/7.
5 | */
6 | public interface HelloService {
7 | String hello(String name);
8 | }
9 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/rpc/service/server/HelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.rpc.service.server;
2 |
3 | import com.snowcattle.game.common.annotation.RpcServiceAnnotation;
4 | import com.snowcattle.game.common.annotation.RpcServiceBoEnum;
5 | import com.snowcattle.game.common.enums.BOEnum;
6 | import com.snowcattle.game.service.rpc.service.client.HelloService;
7 | import org.springframework.stereotype.Repository;
8 |
9 | /**
10 | * Created by jwp on 2017/3/7.
11 | */
12 | @RpcServiceAnnotation(HelloService.class)
13 | @RpcServiceBoEnum(bo = BOEnum.WORLD)
14 | @Repository
15 | public class HelloServiceImpl implements HelloService {
16 |
17 | @Override
18 | public String hello(String name) {
19 | return "Hello! " + name;
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/time/TimeService.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.time;
2 |
3 | /**
4 | * 提供时间相关的服务
5 | *
6 | *
7 | */
8 | public interface TimeService {
9 | /**
10 | * 当前时间
11 | *
12 | * @return
13 | */
14 | public long now();
15 |
16 | /**
17 | * 更新当前时间,只有在当前时间服务使用了缓存策略的情况下才需要调用此方法
18 | */
19 | public void update();
20 |
21 | /**
22 | * 是否到达某个时间
23 | *
24 | * @param sometime
25 | * @return
26 | */
27 | public boolean timeUp(long sometime);
28 |
29 | /**
30 | * 获取指定时间与当前时间的时间差
31 | *
32 | * @param sometime
33 | * @return
34 | */
35 | public long getInterval(long sometime);
36 |
37 | /**
38 | * 获取时间偏移量
39 | *
40 | * @return
41 | *
42 | */
43 | public long getOffset();
44 |
45 | /**
46 | * 设置时间偏移量
47 | *
48 | * @param value 单位: 毫秒
49 | */
50 | public void setOffset(long value);
51 | }
52 |
--------------------------------------------------------------------------------
/game-core/src/main/java/com/snowcattle/game/service/uuid/LongIdGenerator.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.service.uuid;
2 |
3 | import org.springframework.stereotype.Service;
4 |
5 | import java.util.concurrent.atomic.AtomicLong;
6 | /**
7 | * Created by jwp on 2017/2/9.
8 | * sessionId生成器
9 | */
10 | @Service
11 | public class LongIdGenerator {
12 |
13 | protected AtomicLong id_gen = new AtomicLong(0);
14 |
15 | public long generateId(){
16 | return id_gen.incrementAndGet();
17 | }
18 | }
--------------------------------------------------------------------------------
/game-core/src/main/resources/bean/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/dynamic_config.properties:
--------------------------------------------------------------------------------
1 | udp_message_tocken_check_flag=false
--------------------------------------------------------------------------------
/game-core/src/main/resources/game_server_diff.cfg.js:
--------------------------------------------------------------------------------
1 | config.version="0.2.0.1";
2 | //每秒钟处理消息数量
3 | config.session_prcoss_message_max_size=10;
4 | //异步通讯链接保持活跃时间(秒)
5 | config.rpcTcpHeartKeepAliveTime=60*60*24;
6 | //是否启动zookeeper
7 | config.zookeeperFlag=false;
8 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/http-server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | http_server
5 | 11001
6 | 127.0.0.1
7 | 10200
8 | false
9 | 300
10 |
11 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/proxy-server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | proxy-gate
5 | 11001
6 | 127.0.0.1
7 | 9090
8 |
9 |
10 | 127.0.0.1
11 | 7090
12 |
13 |
14 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/rpc-server-register.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/rpc-service-register.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/udp-server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | udp_server
5 | 11001
6 | 127.0.0.1
7 | 10090
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/websocket-server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | web_socket_server
5 | 11001
6 | 127.0.0.1
7 | 10300
8 | true
9 | 300
10 |
11 |
--------------------------------------------------------------------------------
/game-core/src/main/resources/zookeeper.properties:
--------------------------------------------------------------------------------
1 | # zookeeper server
2 | registry.address=127.0.0.1:2181
--------------------------------------------------------------------------------
/game-core/src/test/java/com/snowcattle/game/common/codec/server/CodeSocketTwoServerHandler.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.codec.server;
2 |
3 | import io.netty.channel.ChannelHandlerContext;
4 | import io.netty.channel.SimpleChannelInboundHandler;
5 |
6 | /**
7 | * Created by jiangwenping on 2017/11/13.
8 | */
9 | public class CodeSocketTwoServerHandler extends SimpleChannelInboundHandler {
10 |
11 | @Override
12 | protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
13 | Thread.sleep(1000L);
14 | // ctx.writeAndFlush(msg);
15 | System.out.println("服务端收到:"+msg);
16 | }
17 |
18 |
19 | @Override
20 | public void channelReadComplete(ChannelHandlerContext ctx) {
21 | ctx.flush();
22 | }
23 |
24 | @Override
25 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
26 | // Close the connection when an exception is raised.
27 | cause.printStackTrace();
28 | ctx.close();
29 | }
30 |
31 |
32 |
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/game-core/src/test/java/com/snowcattle/game/common/codec/server/TwoStringDecoder.java:
--------------------------------------------------------------------------------
1 | package com.snowcattle.game.common.codec.server;
2 |
3 | import io.netty.channel.ChannelHandlerContext;
4 | import io.netty.handler.codec.MessageToMessageDecoder;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by jiangwenping on 2017/11/14.
10 | */
11 | public class TwoStringDecoder extends MessageToMessageDecoder {
12 |
13 | @Override
14 | protected void decode(ChannelHandlerContext ctx, String msg, List