Пример #1
0
    public override void OnOperationResponse(OperationResponse resp)
    {
        string        usernameListJson = (string)DictUtil.GetValue(resp.Parameters, (byte)ParameterCode.UsernameList);
        List <string> usernameList     = JsonMapper.ToObject <List <string> >(usernameListJson);

        _player.OnSyncPlayerResponse(usernameList);
    }
Пример #2
0
    public override void OnEvent(EventData eventData)
    {
        string playerDataList             = (string)DictUtil.GetValue(eventData.Parameters, (byte)ParameterCode.PlayerDataList);
        List <PlayerPositionData> posData = JsonMapper.ToObject <List <PlayerPositionData> >(playerDataList);

        _player.OnSyncPositionEvent(posData);
    }
Пример #3
0
 public void OnSyncPositionEvent(List <PlayerPositionData> posData)
 {
     foreach (PlayerPositionData data in posData)
     {
         if (!username.Equals(data.Username))
         {
             GameObject player = DictUtil.GetValue(playerDict, data.Username);
             player.transform.position = new Vector3((float)data.Pos.X, (float)data.Pos.Y, (float)data.Pos.Z);
         }
     }
 }
Пример #4
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters,
                                                ClientPeer clientPeer)
        {
            Dictionary <byte, object> data = operationRequest.Parameters;
            string            username     = DictUtil.GetValue(data, (byte)ParameterCode.Username) as string;
            string            password     = DictUtil.GetValue(data, (byte)ParameterCode.Password) as string;
            IUserDAO          dao          = new IUserDAOImpl();
            Users             u            = new Users(username, password);
            OperationResponse resp         = new OperationResponse(operationRequest.OperationCode);

            resp.ReturnCode = (short)(dao.Register(u) ? ReturnCode.RegisterSuccess : ReturnCode.RegisterFailed);
            clientPeer.SendOperationResponse(resp, sendParameters);
        }
Пример #5
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer clientPeer)
        {
            float positionX = (float)DictUtil.GetValue(operationRequest.Parameters, (byte)ParameterCode.PositionX);
            float positionY = (float)DictUtil.GetValue(operationRequest.Parameters, (byte)ParameterCode.PositionY);
            float positionZ = (float)DictUtil.GetValue(operationRequest.Parameters, (byte)ParameterCode.PositionZ);

            if (clientPeer is MyClientPeer peer)
            {
                peer.x = positionX;
                peer.y = positionY;
                peer.z = positionZ;
            }
        }
Пример #6
0
        //处理客户端请求
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            BaseHandler handler = DictUtil.GetValue(PosSynServer.Instance.handlerDict,
                                                    (OperationCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            else
            {
                handler = DictUtil.GetValue(PosSynServer.Instance.handlerDict, OperationCode.Default);
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
        }
Пример #7
0
        // Get information of the current user as a `Person`.
        public Person GetUser()
        {
            var settingsPath = Locator.Locate("mmsetting.archive");
            var settings     = Unarchiver.DeepParse(PropertyListParser.Parse(settingsPath));
            var me           = new Person();

            DictUtil.TryGet(settings, "UsrName", out me.UsrName);
            DictUtil.TryGet(settings, "AliasName", out me.Alias);
            DictUtil.TryGet(settings, "NickName", out me.NickName);
            if (DictUtil.TryGetSubclass(settings, "new_dicsetting", out var setting))
            {
                DictUtil.TryGet(setting, "headimgurl", out me.Portrait);
                DictUtil.TryGet(setting, "headhdimgurl", out me.PortraitHD);
            }
            return(me);
        }
Пример #8
0
        private static MBFile ReadFileBlob(Stream blob)
        {
            var dict   = Unarchiver.DeepParse(PropertyListParser.Parse(blob));
            var mbFile = new MBFile();

            DictUtil.TryGet(dict, "RelativePath", out mbFile.RelativePath);
            DictUtil.TryGet(dict, "Target", out mbFile.Target);
            DictUtil.TryGet(dict, "Mode", out mbFile.Mode);
            DictUtil.TryGet(dict, "InodeNumber", out mbFile.InodeNumber);
            DictUtil.TryGet(dict, "UserID", out mbFile.UserID);
            DictUtil.TryGet(dict, "GroupID", out mbFile.GroupID);
            DictUtil.TryGet(dict, "LastModified", out mbFile.LastModified);
            DictUtil.TryGet(dict, "LastStatusChange", out mbFile.LastStatusChange);
            DictUtil.TryGet(dict, "Birth", out mbFile.Birth);
            DictUtil.TryGet(dict, "Size", out mbFile.Size);
            DictUtil.TryGet(dict, "ProtectionClass", out mbFile.ProtectionClass);
            return(mbFile);
        }
Пример #9
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters,
                                                ClientPeer clientPeer)
        {
            Dictionary <byte, object> data = operationRequest.Parameters;
            string            username     = DictUtil.GetValue(data, (byte)ParameterCode.Username) as string;
            string            password     = DictUtil.GetValue(data, (byte)ParameterCode.Password) as string;
            IUserDAO          dao          = new IUserDAOImpl();
            Users             u            = new Users(username, password);
            OperationResponse resp         = new OperationResponse(operationRequest.OperationCode);

            resp.ReturnCode = (short)(dao.Verify(u) ? ReturnCode.LoginSuccess : ReturnCode.LoginFailed);
            if (resp.ReturnCode == (short)ReturnCode.LoginSuccess)
            {
                MyClientPeer peer = clientPeer as MyClientPeer;
                if (peer != null)
                {
                    peer.username = username;
                }
            }

            clientPeer.SendOperationResponse(resp, sendParameters);
        }
Пример #10
0
        public static void FillMissingConfigFields(ConfigJson config, string referenceConfigFile = "")
        {
            if (referenceConfigFile == "")
            {
                referenceConfigFile = ConfigVars.DEFAULT_CONFIG_FILE;
            }

            try
            {
                ConfigJson defaultConfig = LoadConfig(referenceConfigFile);

                List <string> exceptionList = new List <string>()
                {
                    ConfigVars.CONFIG_CRYPTO_CURRENCIES, ConfigVars.CONFIG_STARTING_PORTFOLIO, ConfigVars.CONFIG_EXCHANGES, ConfigVars.CONFIG_CATEGORY_SERVICES
                };

                DictUtil.CheckAndMergeValuesFromReference(config, defaultConfig, exceptionList);
            }
            catch (Exception exc)
            {
                var logger = Application.Resolve <ILoggingService>();
                logger.Warning($"Невозможно проверить целостность файла конфигурации ({exc.Message})");
            }
        }
Пример #11
0
    public override void OnEvent(EventData eventData)
    {
        string username = (string)DictUtil.GetValue(eventData.Parameters, (byte)ParameterCode.Username);

        _player.OnNewPlayerEvent(username);
    }