Exemple #1
0
        protected override void ProcessResponse(Envelope envelope)
        {
            if (envelope.Message.GetType() == typeof(LoginRequest))
            {
                LoginRequest received = (LoginRequest)envelope.Message;
                ProcessInfo  newInfo  = new ProcessInfo
                {
                    EndPoint = envelope.Address,
                    Label    = received.ProcessLabel,
                    Type     = received.ProcessType
                };
                ProcessInfo procResponse = OnLoginUpdated?.Invoke(newInfo);

                LoginReply reply = new LoginReply(envelope.ConvId)
                {
                    Success = (procResponse != null && procResponse?.Status == ProcessInfo.StatusCode.Registered)
                };
                reply.Note        = (reply.Success) ? "Granted!" : "Bad request";
                reply.ProcessInfo = procResponse;

                Envelope env = new Envelope(envelope.Address, reply);
                SendMessage(env);
            }
            else
            {
                Logger.Info("Received unexpected message: " + envelope.Message);
            }

            WaitingForReply      = false;
            AllowInboundMessages = false;
        }
        private static void Share(LoginReply data, bool isClientless)
        {
            if (data != null)
            {
                if (data.Result == 1)
                {
                    Metadata.Globals.session = data.Session;
                    if (isClientless)
                    {
                        ThreadProxy.ProxyClientless.SetAgentRemoteEndPoint(data.AgentRemoteEP);
                        ThreadProxy.ProxyClientless.StartAgent();
                    }
                    else
                    {
                        ThreadProxy.Proxy.SetAgentRemoteEndPoint(data.AgentRemoteEP);

                        var agentLocalEP = ThreadProxy.Proxy.GetAgentLocalEndPoint();
                        var packet       = GeneratePacket.LoginReply(data.Result, data.Session, agentLocalEP.Address.ToString(), (ushort)agentLocalEP.Port);
                        ThreadProxy.Proxy.SendPacketToGatewayLocal(packet);

                        ThreadProxy.Proxy.StartAgent();
                    }
                }
            }
        }
        public async Task <HttpResponseMessage> LoginUserAsync([FromBody] JObject jObject)
        {
            var info     = JsonConvert.DeserializeObject <Dictionary <string, string> >(jObject.ToString());
            var response = new HttpResponseMessage();
            var userInfo = new User();
            var debug    = new Debugger();

            if (!Validator.LoginValidator(info["username"], info["password"]))
            {
                response.StatusCode = HttpStatusCode.BadRequest;
                debug.Log(jObject.ToString());
                response.ReasonPhrase = "Username or Password format is invalid";
                return(response);
            }

            try
            {
                userInfo = await _da.LoginUser(info["username"], info["password"]);
            }
            catch (UserNameDoesNotExistException e)
            {
                response.ReasonPhrase = e.Message;
                response.StatusCode   = HttpStatusCode.BadRequest;
                return(response);
            }
            response.StatusCode = HttpStatusCode.OK;
            var loginReply = new LoginReply(userInfo);

            response.ReasonPhrase = JsonConvert.SerializeObject(loginReply);
            return(response);
        }
Exemple #4
0
    public override async Task <GrpcResponse> Login(LoginRequest request, ServerCallContext context)
    {
        var loginDto    = _mapper.Map <UserLoginDto>(request);
        var loginResult = await _accountService.LoginAsync(loginDto);

        var grpcResponse = new GrpcResponse()
        {
            IsSuccessStatusCode = loginResult.IsSuccess
        };

        if (!grpcResponse.IsSuccessStatusCode)
        {
            grpcResponse.Error = loginResult.ProblemDetails?.Detail;
            return(grpcResponse);
        }

        var validatedInfo = loginResult.Content;
        var loginReply    = new LoginReply
        {
            Token        = JwtTokenHelper.CreateAccessToken(_jwtOptions.Value, validatedInfo.ValidationVersion, validatedInfo.Account, validatedInfo.Id.ToString(), validatedInfo.Name, validatedInfo.RoleIds).Token,
            RefreshToken = JwtTokenHelper.CreateRefreshToken(_jwtOptions.Value, validatedInfo.ValidationVersion, validatedInfo.Id.ToString()).Token
        };

        grpcResponse.Content = Any.Pack(loginReply);
        return(grpcResponse);
    }
Exemple #5
0
		private void _createLoginMembers()
		{
			m_login_responseEvent = new AutoResetEvent(false);
			m_login_reply = LoginReply.THIS_IS_WRONG;

			m_client.AddPacketHandler(new FamilyActionPair(PacketFamily.Login, PacketAction.Reply), _handleLoginReply, false);
		}
Exemple #6
0
    //private string url = "login_user.php";
    //?app_user_name=saqib&app_user_pass=1234";

    public void OnClick()
    {
        if (!emailText.Text.ToString().Equals("") && !passText.Text.ToString().Equals(""))
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "login_user.php?user_name=" + emailText.Text.ToString() + "&user_pass="******"OWN";

                    Tween.Play();
                    Tween.TweenCompleted += (dfTweenPlayableBase sender) => {
                        SceneManager.LoadScene("introduction");
                    };
                }
                else
                {
                }
            })
            .Send();
        }
    }
Exemple #7
0
        public static void Main(string[] args)
        {
            var config = new Configuration();

            config.Language = (int)Login.AvailableLanguages.EN;

            var email    = "my_email";
            var password = "******";

            var loginReply = new Login().UserLogin(email, password, config);

            if (loginReply == null)
            {
                Console.WriteLine("There was a problem while loggin in...");
                return;
            }

            var token = new LoginReply().GetToken(loginReply);

            if (String.IsNullOrEmpty(token))
            {
                Console.WriteLine("ERROR: Token could not be acquired.");
                return;
            }

            Console.WriteLine("Token is: " + token);


            var devicesList = new ListDevices().GetDevices(token, config);



            Console.ReadLine();
        }
Exemple #8
0
        private void _createLoginMembers()
        {
            m_login_responseEvent = new AutoResetEvent(false);
            m_login_reply         = LoginReply.THIS_IS_WRONG;

            m_client.AddPacketHandler(new FamilyActionPair(PacketFamily.Login, PacketAction.Reply), _handleLoginReply, false);
        }
        private void Login(User user, string Id, byte[] Password)
        {
            Authority  userAuthority = Base.Security.GetUserAuthority(Id, Password);
            LoginReply reply         = new LoginReply(user.ClientId, userAuthority, BaseConfiguration.ServerVersion);

            if (userAuthority > Authority.None)
            {
                user.Login(Id);
                user.Send <LoginReply>(reply);
                ClientInfoMessage clientInfo = Base.ClientServer.GetClientInfo();
                lock (this.log)
                {
                    clientInfo.AddLog(this.log);
                }
                user.Send <ClientInfoMessage>(clientInfo);
                foreach (Emergency.EmergencyInformation information in Base.Emergency.Emergencies)
                {
                    EmergencyCallMessage message = new EmergencyCallMessage();
                    message.AddEmergencyCallInfo(information.Department, information.ID, information.Name, information.PhoneNumber, information.Mail, information.Rank);
                    user.Send <EmergencyCallMessage>(message);
                }
            }
            else
            {
                user.Send <LoginReply>(reply);
            }
        }
Exemple #10
0
        public bool LoginRequest(string user, string pass, out LoginReply reply, out CharacterRenderData[] data)
        {
            reply = LoginReply.THIS_IS_WRONG;
            data  = null;
            if (!m_client.ConnectedAndInitialized || !Initialized)
            {
                return(false);
            }

            Packet pkt = new Packet(PacketFamily.Login, PacketAction.Request);

            pkt.AddBreakString(user);
            pkt.AddBreakString(pass);

            if (!m_client.SendPacket(pkt) || !m_login_responseEvent.WaitOne(Constants.ResponseTimeout))
            {
                return(false);
            }

            reply = m_login_reply;
            if (reply == LoginReply.Ok && m_character_data != null)
            {
                data = m_character_data;
            }

            return(true);
        }
Exemple #11
0
        //handler for LOGIN_REPLY received from server
        private void _handleLoginReply(Packet pkt)
        {
            m_login_reply = (LoginReply)pkt.GetShort();

            if (m_login_reply == LoginReply.Ok)
            {
                byte numCharacters = pkt.GetChar();
                pkt.GetByte();
                pkt.GetByte();

                m_character_data = new CharacterRenderData[numCharacters];

                for (int i = 0; i < numCharacters; ++i)
                {
                    CharacterRenderData nextData = new CharacterRenderData(pkt);
                    m_character_data[i] = nextData;
                    if (255 != pkt.GetByte())
                    {
                        return;                         //malformed packet - time out and signal error
                    }
                }
            }

            m_login_responseEvent.Set();
        }
Exemple #12
0
        public IHttpActionResult Login(LoginRequest login)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Verifique los datos ingresados."));
                }

                string sessionToken = Guid.NewGuid().ToString();
                User   user         = this.userService.GetUser(login.UserName, login.Password);

                if (user == null)
                {
                    this.userService.LockkUser(login.UserName);
                    return(Unauthorized());
                }

                this.userService.Login(user, sessionToken);

                var reply = new LoginReply
                {
                    Token = sessionToken
                };

                return(Ok(reply));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #13
0
    public void OnClick()
    {
        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!emailText.Text.ToString().Equals("") && !passText.Text.ToString().Equals(""))
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "login_user.php?user_name=" + emailText.Text.ToString() + "&user_pass="******"OWN";
                    GameConstant.UserEmail   = loginReply.data[0].user_email;
                    GameConstant.UserCountry = loginReply.data[0].user_country;
                    GameConstant.IsMusic     = loginReply.data[0].ismusic;
                    GameConstant.IsSound     = loginReply.data[0].issound;
                    //Debug.Log(gameConsatant.user_country);
                    SceneManager.LoadScene("TriviaGamePlay");
                }
                else
                {
                    invalidText.IsVisible = true;
                }
            })
            .Send();
        }
    }
        public static LoginReply Login()
        {
            ILJLogin     loginProxy = CreateProxy <ILJLogin>();
            LoginRequest request    = new LoginRequest();

            request.PopulateWithLoginInfo();
            LoginReply reply = loginProxy.Login(request);

            return(reply);
        }
Exemple #15
0
        public override async Task <LoginReply> Login(LoginRequest request, ServerCallContext context)
        {
            var model = new LoginReply
            {
                Id    = "sdf",
                Token = ""
            };

            return(await Task.FromResult(model));
        }
Exemple #16
0
        public override Task <LoginReply> Login(LoginRequest request, ServerCallContext context)
        {
            //_logger.LogInformation(JsonConvert.SerializeObject(request));
            //_logger.LogInformation(JsonConvert.SerializeObject(_session));
            var model = new LoginReply
            {
                Id    = Guid.NewGuid().ToString("N"),
                Token = Guid.NewGuid().ToString("N").Substring(8, 16)
            };

            return(Task.FromResult(model));
        }
        private void HandleLogin(Login payload, PayloadWriter writer)
        {
            byte[] loginKey = payload.Key;

            _sharedSecret = Crypto.CreateSecretKey();
            byte[] result = Crypto.HandleKey(loginKey, _sharedSecret);

            LoginReply resultPayload = Payloads.CreatePayload <LoginReply>();

            resultPayload.Cipher   = result;
            resultPayload.TicketId = payload.TicketId;
            SendReply(writer, resultPayload);
        }
Exemple #18
0
        public override Task <LoginReply> Login(LoginRequest request, ServerCallContext context)
        {
            LoginReply reply = new LoginReply {
                Status = "401", Token = "用户名或者密码无效"
            };

            if (request.Username == "gavin" && request.Password == "gavin")
            {
                reply.Token  = CreateToken(request.Username);
                reply.Status = "200";
            }
            Console.WriteLine($"call login: username:{request.Username} ,password:{request.Password}, return token:{reply.Token}");
            return(Task.FromResult(reply));
        }
 protected override void ProcessResponse(Envelope envelope)
 {
     if (envelope.Message != null && envelope.Message.GetType() == typeof(LoginReply))
     {
         LoginReply replyMessage = (LoginReply)envelope.Message;
         Logger.Info("Received Login response: " + replyMessage.Note);
         MyProcess       = replyMessage.ProcessInfo;
         WaitingForReply = false;
     }
     else
     {
         Logger.Info("Received unexpected message: " + envelope.Message.ToString());
     }
 }
    private void STocLoginReply(object data)
    {
        LoginReply reply = data as LoginReply;

        if (ERROR_CODE.Ok == reply.Error)
        {
            Debug.Log("Ok");

            GameDataManager.Instance.userData.loginKey  = reply.LoginKey;
            GameDataManager.Instance.userData.accessKey = reply.AccessKey;
            GameDataManager.Instance.userData.nickName  = reply.NickName;
            //usn_ = reply.Usn;

            GameDataManager.Instance.SaveUserDataLoginParts();
            GameDataManager.Instance.LoadGameData();

            //// 헬스체크 시작
            //HealthCheckRequest healthCheckRequest = new HealthCheckRequest();
            //healthCheckRequest.Service = "yyb";

            //// 요청
            //RpcServiceManager.Instance.Check(healthCheckRequest,
            //    (HealthCheckResponse HealthCheckReply) =>
            //{
            //    // 응답
            //    Debug.Log("Check Response : " + HealthCheckReply.ToString());
            //});

            //// 요청
            //RpcServiceManager.Instance.Watch(healthCheckRequest,
            //    (HealthCheckResponse HealthCheckReply) =>
            //{
            //    // 응답
            //    Debug.Log("Watch Response : " + HealthCheckReply.ToString());
            //});
        }
        else if (ERROR_CODE.TheVersionDoesNotMatch == reply.Error)
        {
            Debug.Log(reply.Error);

            // 버전체크 실패
        }
        else
        {
            Debug.Log(reply.Error);
            GameDataManager.Instance.CheckUpdateVersion();
            //DeletePlayerPrefs();
        }
    }
Exemple #21
0
        public static IPacket ReadPacket(this BinaryReader @this)
        {
            if (@this.BaseStream.Length - @this.BaseStream.Position < 7)
            {
                return(null);
            }

            var packetId = (PacketId)@this.ReadInt16();

            return(packetId switch
            {
                PacketId.OutLoginReply => LoginReply.FromReader(@this, PacketSerializationMode.ReadCompression),
                PacketId.OutAnnouncement => Announcement.FromReader(@this, PacketSerializationMode.ReadCompression),

                _ => null
            });
Exemple #22
0
    // Use this for initialization
    void Start()
    {
        base.Init();

        system = EventSystem.current;

        errorText = GameObject.Find("ErrorText").GetComponent <Text>();
        userField = GameObject.Find("usernameEdit").GetComponent <InputField>();
        passField = GameObject.Find("passwordEdit").GetComponent <InputField>();

        UserManager.Instance.registerCallback(UserOperation.LOGIN, (object obj) =>
        {
            funcQueue.Enqueue(() => {
                LoginReply packet = (LoginReply)obj;

                LoginStatus loginStatus = (LoginStatus)packet.response;

                string loginmessage = string.Empty;


                switch (loginStatus)
                {
                case LoginStatus.VALID:
                    errorText.text = "";
                    Application.LoadLevel("charSelect");
                    break;

                case LoginStatus.NOT_EXIST:
                    userField.text = "";
                    passField.text = "";
                    errorText.text = "Username or password invalid";
                    break;

                case LoginStatus.ERROR:
                    userField.text = "";
                    passField.text = "";
                    errorText.text = "There was an error";
                    break;

                default:
                    break;
                }
            });
        });
    }
Exemple #23
0
 protected override void ProcessResponse(Envelope envelope)
 {
     if (envelope?.Message != null && envelope.Message?.GetType() == typeof(LoginReply))
     {
         LoginReply replyMessage = (LoginReply)envelope.Message;
         Logger.Info("Received Login response: " + replyMessage.Note);
         OnLoginUpdated?.Invoke(ProcessInfo.DeepCopy(replyMessage.ProcessInfo));
         WaitingForReply = false;
     }
     else if (envelope != null)
     {
         Logger.Info("Received unexpected message: " + envelope.Message?.ToString());
     }
     else
     {
         Logger.Info("Received completely null envelope");
     }
 }
        public static LoginReply Parse(Packet packet)
        {
            LoginReply loginReply = new LoginReply();

            byte result = packet.ReadUInt8();

            if (result == 0x01)
            {
                uint   session = packet.ReadUInt32();
                string ip      = packet.ReadAscii();
                ushort port    = packet.ReadUInt16();

                loginReply = new LoginReply
                {
                    Result        = result,
                    Session       = session,
                    AgentRemoteEP = new IPEndPoint(IPAddress.Parse(ip), port)
                };
            }

            return(loginReply);
        }
Exemple #25
0
        public override Task <LoginReply> SignIn(LoginRequest request, ServerCallContext context)
        {
            var userId   = request.Id;
            var password = request.Password;

            _logger.LogInformation(userId);
            _logger.LogInformation(password);

            var user = _userRepository.GetUser(userId);

            var httpContext = context.GetHttpContext();



            var loginReply = new LoginReply
            {
                Result  = true,
                Message = "登录成功"
            };

            return(Task.FromResult(loginReply));
        }
Exemple #26
0
		public bool LoginRequest(string user, string pass, out LoginReply reply, out CharacterRenderData[] data)
		{
			reply = LoginReply.THIS_IS_WRONG;
			data = null;
			if (!m_client.ConnectedAndInitialized || !Initialized)
				return false;

			Packet pkt = new Packet(PacketFamily.Login, PacketAction.Request);
			pkt.AddBreakString(user);
			pkt.AddBreakString(pass);

			if(!m_client.SendPacket(pkt) || !m_login_responseEvent.WaitOne(Constants.ResponseTimeout))
				return false;

			reply = m_login_reply;
			if (reply == LoginReply.Ok && m_character_data != null)
			{
				data = m_character_data;
			}

			return true;
		}
        public void ShowLoginError(LoginReply loginError)
        {
            DialogResourceID message;

            switch (loginError)
            {
            case LoginReply.WrongUser: message = DialogResourceID.LOGIN_ACCOUNT_NAME_NOT_FOUND; break;

            case LoginReply.WrongUserPass: message = DialogResourceID.LOGIN_ACCOUNT_NAME_OR_PASSWORD_NOT_FOUND; break;

            case LoginReply.LoggedIn: message = DialogResourceID.LOGIN_ACCOUNT_ALREADY_LOGGED_ON; break;

            case LoginReply.Busy: message = DialogResourceID.CONNECTION_SERVER_IS_FULL;  break;

            default: throw new ArgumentOutOfRangeException(nameof(loginError), loginError, null);
            }

            var messageBox = _messageBoxFactory.CreateMessageBox(message,
                                                                 EODialogButtons.Ok,
                                                                 EOMessageBoxStyle.SmallDialogLargeHeader);

            messageBox.ShowDialog();
        }
Exemple #28
0
		//handler for LOGIN_REPLY received from server
		private void _handleLoginReply(Packet pkt)
		{
			m_login_reply = (LoginReply)pkt.GetShort();

			if (m_login_reply == LoginReply.Ok)
			{
				byte numCharacters = pkt.GetChar();
				pkt.GetByte();
				pkt.GetByte();

				m_character_data = new CharacterRenderData[numCharacters];

				for (int i = 0; i < numCharacters; ++i)
				{
					CharacterRenderData nextData = new CharacterRenderData(pkt);
					m_character_data[i] = nextData;
					if (255 != pkt.GetByte())
						return; //malformed packet - time out and signal error
				}
			}

			m_login_responseEvent.Set();
		}
Exemple #29
0
    async Task Login()
    {
        Channel channel = new Channel(ServiceUrl, ChannelCredentials.Insecure);

        var        client = new GameService.Lobby.LobbyClient(channel);
        LoginReply reply  = null;


        using (var call = client.Login(new LoginRequest {
            Name = ""
        }))
        {
            var responseStream = call.ResponseStream;

            while (await responseStream.MoveNext())
            {
                reply      = responseStream.Current;
                session_id = reply.SessionId;
                Debug.Log(string.Format("SessionId {0}", session_id));
            }
        }

        await channel.ShutdownAsync();
    }
Exemple #30
0
 private void AddAccessToken(LoginReply json)
 {
     logger($"Token found: {json.access_token}");
     client.DefaultRequestHeaders.Add("Authorization", $"Bearer {json.access_token}");
 }
Exemple #31
0
        private async void ApplicationBarIconButton_OnClick(object sender, EventArgs e)
        {
            if (IsBusy)
            {
                IsBusy = true;
            }
            StateService.ProgressIndicatorService.Show("Logging in...");

            var offLineMode = false;

            LoginReply login = null;

            if (!Helpers.IsNetworkAvailable && StateService.Login == tbLogin.Text && StateService.Password == tbPassword.Password)
            {
                login = new LoginReply()
                {
                    UserId = StateService.CurrentUserId, IsSuccess = true
                };
                offLineMode = true;
                Helpers.LogEvent("Login", new Dictionary <string, string> {
                    { "UserId", StateService.CurrentUserId.ToString() }, { "AppVersion", Helpers.GetAppVersion() }
                });
                MessageBox.Show("Working in Offline mode. Data will be synched when internet connection becomes available");
            }
            else
            {
                login = await new MyNetmeraClient().Login(tbLogin.Text, tbPassword.Password);
            }


            if (ApiResponseProcessor.Execute(login))
            {
                StateService.CurrentUserType = (ESurveyorType)login.Type;

                Guid userId = login.UserId.Value;

                Helpers.LogEvent("Login", new Dictionary <string, string> {
                    { "UserId", userId.ToString() }, { "AppVersion", Helpers.GetAppVersion() }
                });

                if (StateService.PreviousUserId != userId)
                {
                    if (SyncEngine.IsSyncing)
                    {
                        MessageBox.Show("Syncing now, wait");
                        StateService.ProgressIndicatorService.Hide();
                        IsBusy = false;
                        return;
                    }

                    if (StateService.CurrentUserId == Guid.Empty)
                    {
                        StateService.CurrentUserId = userId;
                    }

                    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;


                    StateService.ProgressIndicatorService.Hide();
                    StateService.ProgressIndicatorService.Show("Syncing previous user data");

                    await SyncEngine.Sync(true);

                    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

                    StateService.ProgressIndicatorService.Hide();
                    StateService.ProgressIndicatorService.Show("Clearing database");

                    await new DbService().ClearDb();

                    if (StateService.IsQA)
                    {
                        var myQaAddresses =
                            DataLoaderService.Convert <QAAddress, ServiceReference.QAAddress>(login.QaAddresses);

                        await new DbService().Save(myQaAddresses);

                        var myQaAddressesComments =
                            DataLoaderService.Convert <QAAddressComment, ServiceReference.QAAddressComment>(login.QaAddressComments);

                        await new DbService().Save(myQaAddressesComments);
                    }


                    StateService.ProgressIndicatorService.Hide();
                    StateService.ProgressIndicatorService.Show("Loading data");

                    bool isError = false;
                    StateService.CurrentUserTimeStamp = login.Timestamp;
                    StateService.CurrentUserId        = userId;
                    try
                    {
                        await new MyNetmeraClient().DownloadUserData();
                    }
                    catch (Exception exc)
                    {
                        isError = true;
                        Helpers.LogException(exc, "DownloadUserData");
                        MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while loading data. Try again" : exc.Message);
                    }

                    if (isError)
                    {
                        await new MyNetmeraClient().ClearDb();
                    }

                    StateService.ProgressIndicatorService.Hide();
                    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;

                    if (isError)
                    {
                        return;
                    }

                    StateService.PreviousUserId = userId;

                    StateService.Login    = tbLogin.Text;
                    StateService.Password = tbPassword.Password;
                }
                else
                {
                    bool isError = false;
                    //Process timestamp
                    if (!offLineMode && StateService.CurrentUserTimeStamp != login.Timestamp)
                    {
                        StateService.ProgressIndicatorService.Hide();
                        StateService.ProgressIndicatorService.Show("Refreshing user data");

                        try
                        {
                            await new MyNetmeraClient().RefreshUserData();
                            StateService.CurrentUserTimeStamp = login.Timestamp;
                        }
                        catch (Exception exc)
                        {
                            isError = true;
                            Helpers.LogException(exc, "RefreshUserData");
                            MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while refreshing data. Try again" : exc.Message);
                        }
                    }

                    try
                    {
                        if (!isError)
                        {
                            StateService.ProgressIndicatorService.Hide();
                            StateService.ProgressIndicatorService.Show("Processing address move");
                            await new MyNetmeraClient().RefreshAddressMoves(login.AddressMoves);
                        }
                    }
                    catch (Exception exc)
                    {
                        isError = true;
                        Helpers.LogException(exc, "RefreshAddressMoves");
                        MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while processing address moves. Try again" : exc.Message);
                    }

                    //update address properties
                    try
                    {
                        StateService.ProgressIndicatorService.Hide();
                        StateService.ProgressIndicatorService.Show("Refreshing addresses properties");

                        if (!offLineMode)
                        {
                            await new MyNetmeraClient().RefreshAddressesProperties();
                        }
                    }
                    catch (Exception exc)
                    {
                        isError = true;
                        Helpers.LogException(exc, "RefreshAddressesProperties");
                        MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while refreshing data. Try again" : exc.Message);
                    }
                    //

                    if (isError)
                    {
                        StateService.ProgressIndicatorService.Hide();
                        IsBusy = false;
                        return;
                    }



                    SyncEngine.Sync();
                }

                SyncEngine.InitializeTimer();
                ExNavigationService.Navigate <SelectCustomersPage>();
            }
            StateService.ProgressIndicatorService.Hide();
            IsBusy = false;
        }
Exemple #32
0
        public bool SendAppMsg(string targetPath, string sourceFile, string settingsXML)
        {
            ENSubMsgType enSubMsgType = ENSubMsgType.CONFIG_ADD;
            AppInfo      app          = new AppInfo();

            app.AppId = appTypeSelected + "_" + System.IO.Path.GetFileName(sourceFile);
            Enum.TryParse(appTypeSelected, out ENAppType myStatus);
            app.AppType = myStatus;

            string exePath = targetPath + "\\" + System.IO.Path.GetFileName(sourceFile);

            string[] files = System.IO.Directory.GetFiles(exePath, "*.exe");
            if (files.Count() > 0)
            {
                string fileName = System.IO.Path.GetFileName(files.First());
                app.ExecutablePath = appTypeSelected + "\\" + fileName;
            }
            else
            {
                app.ExecutablePath = appTypeSelected + "\\" + System.IO.Path.GetFileName(sourceFile);
            }



            LoginInfo  loginInfo     = new LoginInfo();
            LoginReply objLoginReply = null;

            loginInfo.UserName = "******";
            loginInfo.Password = "******";
            loginInfo.Topic    = "";

            ProxySettings settings = new ProxySettings();

            m_communicationMgr = new CommunicationManager();
            m_communicationMgr.Init(null, ENAppType.ADMIN, ENClientType.API, settingsXML, null);
            m_communicationMgr.Authenticate(loginInfo, out objLoginReply);

            if (objLoginReply != null && objLoginReply.ErrorCode != 0 && !objLoginReply.Success)
            {
                return(false);
            }

            Message msg = new Message();

            msg.SetMessageType((uint)ENMsgType.CONFIG_APP);
            msg.SetField((uint)ENConfigField.SUB_MSG_TYPE, (int)enSubMsgType);

            msg.SetField((uint)ENConfigField.APP_ID, app.AppId);
            msg.SetField((uint)ENConfigField.APP_TYPE, (int)app.AppType);
            msg.SetField((uint)ENConfigField.EXECUTABLE_PATH, app.ExecutablePath);
            //msg.SetField((uint)ENConfigField.WORKING_DIR, app.WorkingDir);
            //msg.SetField((uint)ENConfigField.ADDITIONAL_PARAMS, app.AdditionalParams);
            msg.SetField((uint)ENConfigField.DESCRIPTION, app.Description);


            msg.SetField((uint)ENConfigField.ADDITIONAL_PARAMS, additionalParams.Text);
            msg.SetField((uint)ENConfigField.WORKING_DIR, workingDirectory.Text);

            Message replyMsg = null;
            int     result   = m_communicationMgr.RequestSync(ENAppType.CONFIG, "", msg, out replyMsg);

            m_communicationMgr.Dispose();
            return(ProcessConfigReply(replyMsg));
        }
Exemple #33
0
 public LoginReply OnLoginRequest(LoginRequest request)
 {
     LoginReplyType replyType;
     if (!IsCompatibleClientVersion(request.ClientVersion))
         replyType = LoginReplyType.IncompatibleVersion;
     else if (NameIsTooLong(request.Name))
         replyType = LoginReplyType.NameTooLong;
     else if (NameIsInUse(request.Name))
         replyType = LoginReplyType.NameInUse;
     else
         replyType = LoginReplyType.Success;
     LoginReply reply = new LoginReply(replyType, Version);
     return reply;
 }
Exemple #34
0
        public LoginReply Login()
        {
            LoginReply response = new LoginReply();

            DebugUtilities.WriteSpecial("Login block was called in Login()");
            if (Client.Network.Connected)
            {
                DebugUtilities.WriteError("Uhm, Login() was called when we where already connected. Hurr");
                return new LoginReply();
            }

            //Client.Network.LoginProgress +=
            //    delegate(object sender, LoginProgressEventArgs e)
            //    {
            //        DebugUtilities.WriteDebug(String.Format("Login {0}: {1}", e.Status, e.Message));

            //        if (e.Status == LoginStatus.Success)
            //        {
            //            DebugUtilities.WriteSpecial("Logged in successfully");
            //            myStatus = Status.Connected;
            //            response.wasFatal = false;
            //            response.xmlReply = "<success><session_id>" + sessionid.ToString() + "</session_id></success>";
            //        }
            //        else if (e.Status == LoginStatus.Failed)
            //        {
            //            DebugUtilities.WriteError("There was an error while connecting: " + Client.Network.LoginErrorKey);
            //            response.wasFatal = true;
            //            response.xmlReply = "<error></error>";
            //        }
            //    };

            // Optimize the throttle
            Client.Throttle.Wind = 0;
            Client.Throttle.Cloud = 0;
            Client.Throttle.Land = 1000000;
            Client.Throttle.Task = 1000000;
            Client.Settings.LOGIN_SERVER = Program.config.networking.loginuri;

            DebugUtilities.WriteDebug("Login URI: " + Client.Settings.LOGIN_SERVER);

            LoginParams loginParams = Client.Network.DefaultLoginParams(
                    First, Last, MD5Password, "RestBot", VERSION);

            if (Client.Network.Login(loginParams))
            {
                DebugUtilities.WriteSpecial("Logged in successfully");
                myStatus = Status.Connected;
                response.wasFatal = false;
                response.xmlReply = "<success><session_id>" + sessionid.ToString() + "</session_id></success>";
            }
            else
            {
                DebugUtilities.WriteError("There was an error while connecting: " + Client.Network.LoginErrorKey);
                switch (Client.Network.LoginErrorKey)
                {
                    case "connect":
                    case "key":
                    case "disabled":
                        response.wasFatal = true;
                        response.xmlReply = "<error fatal=\"true\">" + Client.Network.LoginMessage + "</error>";
                        break;
                    case "presence":
                    case "timed out":
                    case "god":
                        DebugUtilities.WriteWarning("Nonfatal error while logging in.. this may be normal");
                        response.wasFatal = false;
                        response.xmlReply = "<error fatal=\"false\">" + Client.Network.LoginMessage + "</error><retry>10</retry>\n<session_id>" + sessionid + "</session_id>";

                        DebugUtilities.WriteSpecial("Relogin attempt will be made in 10 minutes");
                        ReloginTimer.Interval = 10 * 60 * 1000; //10 minutes
                        ReloginTimer.Start();
                        break;
                    default:
                        DebugUtilities.WriteError(sessionid.ToString() + " UNKNOWN ERROR ATTEMPTING TO LOGIN");
                        response.wasFatal = true;
                        response.xmlReply = "<error fatal=\"true\">Unknown error has occurred.</error>";
                        break;
                }

                if (response.wasFatal == false) myStatus = Status.Reconnecting;
            }
            //Client.Network.BeginLogin(loginParams);
            return response;
        }
Exemple #35
0
        public LoginReply LoginOLD()
        {
            DebugUtilities.WriteSpecial("Login block was called");
            if (Client.Network.Connected)
            {
                DebugUtilities.WriteError("Uhm, Login() was called when we where already connected. Hurr");
                return new LoginReply();
            }

            ReloginTimer.Stop(); //to stop any relogin timers

            myStatus = Status.LoggingIn;
            //Set up some settings
            //Client.Settings.DEBUG = Program.config.debug.slDebug; //obsolete setting?
            Client.Settings.SIMULATOR_TIMEOUT = 30000; //30 seconds
            Client.Settings.MULTIPLE_SIMS = false; //not for now.
            Client.Settings.SEND_PINGS = true;
            Client.Settings.LOGIN_SERVER = Program.config.networking.loginuri;
            Client.Throttle.Total = Program.config.networking.throttle;

            DebugUtilities.WriteDebug("Login URI: " + Client.Settings.LOGIN_SERVER);

            LoginReply response = new LoginReply();
            string start = "";
            if (Program.config.location.startSim.Trim() != "") start = OpenMetaverse.NetworkManager.StartLocation(Program.config.location.startSim, Program.config.location.x, Program.config.location.y, Program.config.location.z);
            else start = "last";

            if (Client.Network.Login(First, Last, MD5Password, "RESTBot", start, "Jesse Malthus / Pleiades Consulting"))
            {
                DebugUtilities.WriteSpecial("Logged in successfully");
                myStatus = Status.Connected;
                response.wasFatal = false;
                response.xmlReply = "<success><session_id>" + sessionid.ToString() + "</session_id></success>";
            }
            else
            {
                DebugUtilities.WriteError("There was an error while connecting: " + Client.Network.LoginErrorKey);
                switch (Client.Network.LoginErrorKey)
                {
                    case "connect":
                    case "key":
                    case "disabled":
                        response.wasFatal = true;
                        response.xmlReply = "<error fatal=\"true\">" + Client.Network.LoginMessage + "</error>";
                        break;
                    case "presence":
                    case "timed out":
                    case "god":
                        DebugUtilities.WriteWarning("Nonfatal error while logging in.. this may be normal");
                        response.wasFatal = false;
                        response.xmlReply = "<error fatal=\"false\">" + Client.Network.LoginMessage + "</error><retry>10</retry>\n<session_id>" + sessionid + "</session_id>";

                        DebugUtilities.WriteSpecial("Relogin attempt will be made in 10 minutes");
                        ReloginTimer.Interval = 10 * 60 * 1000; //10 minutes
                        ReloginTimer.Start();
                        break;
                    default:
                        DebugUtilities.WriteError(sessionid.ToString() + " UNKNOWN ERROR ATTEMPTING TO LOGIN");
                        response.wasFatal = true;
                        response.xmlReply = "<error fatal=\"true\">Unknown error has occurred.</error>";
                        break;
                }

                if (response.wasFatal == false) myStatus = Status.Reconnecting;
            }

            //yay return
            return response;
        }
 private void ProcessMessage(object rawMessage)
 {
     if (rawMessage is LoginReply)
     {
         LoginReply loginReply = rawMessage as LoginReply;
         if (loginReply.Authority == Authority.None)
         {
             if (this.LoginFail != null)
             {
                 this.LoginFail(this, new EventArgs <Exception>(new Exception("Fail to login")));
             }
             this.Stop();
             return;
         }
         if (this.LoginSuccess != null)
         {
             this.LoginSuccess(this, EventArgs.Empty);
             return;
         }
     }
     else
     {
         if (rawMessage is ClientInfoMessage)
         {
             ClientInfoMessage clientInfoMessage = rawMessage as ClientInfoMessage;
             this.workGroups = WorkGroupStructureNode.GetWorkGroup(clientInfoMessage.WorkGroup);
             using (IEnumerator <KeyValuePair <int, RCClient> > enumerator = clientInfoMessage.Clients.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     KeyValuePair <int, RCClient> keyValuePair = enumerator.Current;
                     RCClient rcclient = new RCClient(keyValuePair.Key, keyValuePair.Value.ClientIP);
                     rcclient.AssignFrom(keyValuePair.Value);
                     this.AddClient(rcclient);
                     this.CheckAndAddHeroesAdmin(rcclient);
                 }
                 return;
             }
         }
         if (rawMessage is ClientAddedMessage)
         {
             ClientAddedMessage clientAddedMessage = rawMessage as ClientAddedMessage;
             RCClient           rcclient2          = new RCClient(clientAddedMessage.ID, clientAddedMessage.Client.ClientIP);
             rcclient2.AssignFrom(clientAddedMessage.Client);
             this.AddClient(rcclient2);
             this.CheckAndAddHeroesAdmin(rcclient2);
             return;
         }
         if (rawMessage is ClientRemovedMessage)
         {
             ClientRemovedMessage clientRemovedMessage = rawMessage as ClientRemovedMessage;
             this.RemoveClient(clientRemovedMessage.ID);
             this.CheckAndRemoveHeroesAdmin(clientRemovedMessage.ID);
             return;
         }
         if (rawMessage is ControlReplyMessage)
         {
             ControlReplyMessage controlReplyMessage = rawMessage as ControlReplyMessage;
             if (this.clientList.ContainsKey(controlReplyMessage.ID))
             {
                 this.ProcessClientMessage(new Packet(controlReplyMessage.Packet), this.clientList[controlReplyMessage.ID]);
             }
         }
     }
 }