Пример #1
0
        public ServerMessageProcessor(ServerStateMachine serverStateMachine)
        {
            mLogger = LogManager.GetLogger("ServerMessageProcessor");

            mServerStateMachine = serverStateMachine;

            mServerReflector = new ServerReflector(mServerStateMachine.ConnectionHandler.Disconnect, ReceiveMessageFromReflector);
            mServerReflector.StartServerReflector(StateServerConfig.ServerIp, int.Parse(StateServerConfig.ServerPort));
            // Tell boss server that this server is online
            BossServerAPI.InitStateServer(StateServerConfig.ServerIp, StateServerConfig.ServerPort,
                                          delegate(XmlDocument xmlResponse) {
                XmlNode stateServerNode = xmlResponse.SelectSingleNode("StateServerId");
                if (stateServerNode != null)
                {
                    string stateServerId             = stateServerNode.InnerText;
                    serverStateMachine.StateServerId = stateServerId;
                    mLogger.InfoFormat("Registered with Boss Server as stateserver id = {0}", stateServerId);
                }
                else
                {
                    mLogger.Error("Received an invalid response from BossServer.InitStateServer: " + xmlResponse.OuterXml);
                }
            });

            //TODO: uncomment this to enable admin console
            //mAdminReflector = new ServerReflector(Disconnect, ReceiveMessageFromReflector);
            //mAdminReflector.StartServerReflector(9090);

            //CallToService getFacebookUsers = new CallToService(StateServerConfig.WebServicesBaseUrl + "Facebook/GetTestUsers");
            //getFacebookUsers.Send();
            //XmlDocument response = getFacebookUsers.ServiceResponse;

            //Console.WriteLine(getFacebookUsers.ServiceResponse.OuterXml);
        }
Пример #2
0
        public FashionMinigameServer(ServerStateMachine serverStateMachine) : base(serverStateMachine)
        {
            mEnergyManager = new FashionEnergyManager(mLogger, serverStateMachine.SessionManager.GetServerAccountFromSessionId, SendMessageToClient);

            mMessageActions.Add(MessageSubType.RequestLoadingInfo, BuildFashionGameLoadingInfo);
            mMessageActions.Add(MessageSubType.RequestNpcAssets, GetAvatarsForJob);
            mMessageActions.Add(MessageSubType.GetPlayerData, GetPlayerGameData);
            mMessageActions.Add(MessageSubType.SetPlayerData, SetPlayerGameData);
            mMessageActions.Add(MessageSubType.LevelComplete, SetLevelComplete);
            mMessageActions.Add(MessageSubType.GetFriendsToHire, GetFriendsToHire);
            mMessageActions.Add(MessageSubType.GetAllHiredAvatars, GetAllHiredAvatars);
            mMessageActions.Add(MessageSubType.HireFriend, HireFriend);
            mMessageActions.Add(MessageSubType.UseEnergy, mEnergyManager.UseEnergy);
        }