예제 #1
0
파일: Login.cs 프로젝트: EmergencyX/Client
        /// <summary>
        /// Logs the user asyncrouns in. No parmaeter needed because the needed data is stored in app.config
        /// </summary>
        public async void TokenLogin()
        {
            // SSL Crt (should been placed in Solution Dir with Build Option Copy always)
            //
            SslCredentials cred = new SslCredentials(File.ReadAllText("server.crt"));

            // new Channel and then a new client based on that Channel
            //
            var connectionChannel = new Channel("beta.emergencyx.de:50051", cred);
            var emx = EmergencyExplorerService.NewClient(connectionChannel);

            LoginWithTokenRequest request = new LoginWithTokenRequest {
                UserId = Convert.ToUInt32(AppConfig.readFromAppConfig("userId")), Token = AppConfig.readFromAppConfig("token")
            };
            LoginResponse response = await emx.LoginWithTokenAsync(request);

            connectionChannel.ShutdownAsync().Wait();

            if (response.Success != true)
            {
                throw new NotSuccessFullLoggedInException();
            }
        }