public void Login() { PlayGamesPlatform.Activate(); if (!Application.isEditor) { // Try logging in if it is not running in the editor if (!Social.localUser.authenticated) { Social.localUser.Authenticate((bool success) => { if (!success) { Debug.Log("Fail Login"); } else { Debug.Log("Login Succeed"); } }); } loginEvent.Invoke(isAuthenticated); } else { loginEvent.Invoke(true); } }
/// <summary> /// 登陆连接 /// </summary> /// <param name="host">主机</param> /// <param name="port">端口</param> /// <param name="userId">用户Id</param> /// <param name="userName">用户名</param> /// <param name="userPad">用户密码</param> public void Connect(string host, int port, int userId, string userName, string userPad) { this.host = host; this.port = port; this.userId = userId; if (LoginEvent != null) { Tuple <bool, string, string> tuple = LoginEvent?.Invoke(); if (!tuple.Item1) { return; } userName = tuple.Item2; userPad = tuple.Item3; } var options = new MqttClientOptions { ClientId = this.ClientId, ChannelOptions = new MqttClientTcpOptions() { Server = host, Port = port }, Credentials = new MqttClientCredentials() { Username = userId > 0 ? userId + "" : userName, Password = userId > 0 ? null : userPad, }, CleanSession = true, }; options.KeepAlivePeriod = TimeSpan.FromSeconds(this.keepAlivePeriod); //options.KeepAliveSendInterval = TimeSpan.FromSeconds(15); mqttClient.ConnectAsync(options); }
public void Login() { string accessToken = r_AppSettings.LastAccessToken; if (accessToken != null) { LoggedInUser = FacebookService.Connect(accessToken).LoggedInUser; } else { LoginForm loginForm = new LoginForm(); if (loginForm.ShowDialog() != DialogResult.OK) { Environment.Exit(0); } LoggedInUser = loginForm.LogInInfo.LoggedInUser; r_AppSettings.LastAccessToken = loginForm.LogInInfo.AccessToken; r_AppSettings.SaveToFile(); } if (LoginEvent != null) { LoginEvent.Invoke(); } NextPage(Factory.AppPages[0].GetType().Name.ToLower()); }
private void OnMessage(object sender, MessageEventArgs eventArgs) { if (!eventArgs.IsText) { return; } var container = JsonConvert.DeserializeObject <Container>(eventArgs.Data); switch (container.Identifier) { case DispatchType.Login: if (((JObject)container.Payload).ToObject(typeof(LoginResponseContainer)) is LoginResponseContainer loginResponse) { var eventLog = new EventLogMessage() { IsSuccessfully = true, SenderName = _login, Text = "Login", Time = DateTime.Now, Type = DispatchType.Login }; if (loginResponse.Content.Result == ResponseType.Failure) { eventLog.IsSuccessfully = false; eventLog.Text = loginResponse.Content.Reason; } LoginEvent?.Invoke( this, new LoginEventArgs( _login, eventLog.IsSuccessfully, eventLog, loginResponse.General, loginResponse.OnlineList, loginResponse.OfflineList, loginResponse.EventLogMessageList)); } break; case DispatchType.Message: MessageReceived?.Invoke(this, MessageSorter.GetSortedMessage((JObject)container.Payload)); break; case DispatchType.Channel: UpdateChannel?.Invoke(this, MessageSorter.GetSortedChannel((JObject)container.Payload)); break; case DispatchType.EventLog: LogEvent?.Invoke(this, MessageSorter.GetSortedEventMessage((JObject)container.Payload)); break; default: throw new ArgumentOutOfRangeException(); } }
private void MessageSorter(byte[] buffer, int start, int length, Socket clientSocket) { string content = Encoding.Default.GetString(buffer, 0, length); MessageDictionary messageD = new MessageDictionary(content); ShowMessage("从" + clientSocket.RemoteEndPoint.ToString() + "接收消息:" + content + "\n"); CommandType command = (CommandType)Enum.Parse(typeof(CommandType), messageD[MesKeyStr.CommandType]); switch (command) { case CommandType.Login: { LoginEvent?.Invoke(this, new LoginEventArgs() { UserID = messageD[MesKeyStr.UserID], PassWord = messageD[MesKeyStr.PassWord], ReceiveSocket = clientSocket }); break; } case CommandType.Logout: { LogoutEvent?.Invoke(this, new User(messageD[MesKeyStr.UserID], messageD[MesKeyStr.NickName])); break; } case CommandType.SignUp: { SignUpEvent?.Invoke(this, new SignUpEventArgs(clientSocket, messageD[MesKeyStr.NickName], messageD[MesKeyStr.PassWord])); break; } case CommandType.GroupMessage: { GroupMessageEvent?.Invoke(this, messageD); break; } case CommandType.PrivateMessage: { PrivateMessageEvent?.Invoke(this, messageD); break; } case CommandType.UserJoin: case CommandType.UserQuit: case CommandType.LoginResult: case CommandType.SignUpResult: case CommandType.ServerDisconnect: case CommandType.Remove: { ShowMessage("收到错误的消息类型!"); throw new Exception("收到错误的消息类型!"); } } }
public static IEnumerator Login( Client client, string userId, string password, string accountNamespaceName, string accountEncryptionKeyId, LoginEvent onLogin, ErrorEvent onError ) { AsyncResult <EzAuthenticationResult> result = null; yield return(client.Account.Authentication( r => { result = r; }, accountNamespaceName, userId, accountEncryptionKeyId, password )); if (result.Error != null) { onError.Invoke( result.Error ); yield break; } var account = result.Result.Item; AsyncResult <EzLoginResult> result2 = null; yield return(client.Auth.Login( r => { result2 = r; }, userId, accountEncryptionKeyId, result.Result.Body, result.Result.Signature )); var session = new GameSession( new AccessToken() .WithToken(result2.Result.Token) .WithExpire(result2.Result.Expire) .WithUserId(result2.Result.UserId) ); onLogin.Invoke(account, session); }
private void GetUserInfoCallback(IGraphResult result) { if (!WasErrorInResult(result)) { User.FirstName = result.ResultDictionary[FacebookParameters.User.FirstNameFieldName].ToString(); User.LastName = result.ResultDictionary[FacebookParameters.User.LastNameFieldName].ToString(); loginSuccess.Invoke(User); } else { loginFail.Invoke(); } }
void ISCPacketHandler.HANDLE_SC_Login(long accountId) { if (accountId == -1) { Log.I.Debug($"로그인 실패"); } ClientJobManager.I.ReserveJob(async() => { m_AccountId = accountId; LoginEvent?.Invoke(accountId); }); }
protected internal void OnLoginEvent(OperationContext context, LoginEventType eventType, ILogin login = null, string message = null, string userName = null) { if (context == null && login != null) { context = EntityHelper.GetSession(login).Context; } context?.Log.AddEntry(new AppEventEntry(context.LogContext, "Login", eventType.ToString(), EventSeverity.Info, message: message, guidParam: login?.Id, stringParam: login?.UserName ?? userName)); var args = new LoginEventArgs(eventType, login, context); LoginEvent?.Invoke(this, args); }
protected internal void OnLoginEvent(OperationContext context, LoginEventType eventType, ILogin login = null, string message = null, string userName = null) { if (context == null && login != null) { context = EntityHelper.GetSession(login).Context; } if (_logService != null) { _logService.AddEntry(new EventLogEntry("Login", eventType.ToString(), EventSeverity.Info, message: message, objectId: login?.Id, context: context, objectName: userName)); } var args = new LoginEventArgs(eventType, login, context); LoginEvent?.Invoke(this, args); }
private void GetReceived(object sender, HttpServer.HttpServerGetEvent e) { if (e.Path.StartsWith("/ffxivlauncher/")) { var otp = e.Path.Substring(15); if (otp.Length < 6) { Log.Error("Malformed otp: {0}", otp); MessageBox.Show("Received malformed OTP code, please check macro.\n\nInput:" + (string.IsNullOrEmpty(otp) ? "<empty string>" : otp), "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } OnOtpReceived?.Invoke(otp); } }
/// <summary> /// 开启服务 /// </summary> private async Task <string> CreateMQTTServer(int port) { var optionsBuilder = new MqttServerOptionsBuilder(); try { //在 MqttServerOptions 选项中,你可以使用 ConnectionValidator 来对客户端连接进行验证。比如客户端ID标识 ClientId,用户名 Username 和密码 Password 等。 optionsBuilder.WithConnectionValidator(c => { try { if (LoginEvent != null) { LoginEvent?.Invoke(c); } else { c.ReturnCode = MqttConnectReturnCode.ConnectionAccepted; } } catch { c.ReturnCode = MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword; return; } }); //指定端口 optionsBuilder.WithDefaultEndpointPort(port); //连接记录数,默认 一般为2000 //optionsBuilder.WithConnectionBacklog(2000); mqttServer = new MqttFactory().CreateMqttServer(); // 客户端支持 Connected、Disconnected 和 ApplicationMessageReceived 事件,用来处理客户端与服务端连接、客户端从服务端断开以及客户端收到消息的事情。 //其中 ClientConnected 和 ClientDisconnected 事件的事件参数一个客户端连接对象 ConnectedMqttClient,通过该对象可以获取客户端ID标识 ClientId 和 MQTT 版本 ProtocolVersion。 mqttServer.ClientConnected += MqttServer_ClientConnected; mqttServer.ClientDisconnected += MqttServer_ClientDisconnected; //ApplicationMessageReceived 的事件参数包含了客户端ID标识 ClientId 和 MQTT 应用消息 MqttApplicationMessage 对象,通过该对象可以获取主题 Topic、QoS QualityOfServiceLevel 和消息内容 Payload 等信息。 mqttServer.ApplicationMessageReceived += MqttServer_ApplicationMessageReceived; } catch (Exception ex) { return("MQTT服务创建失败>" + ex.Message); } await mqttServer.StartAsync(optionsBuilder.Build()); return("MQTT服务<0.0.0.0:" + port + ">已启动"); }
private static void OnLoginEvent() { LoginEvent?.Invoke(null, EventArgs.Empty); }
private void Login() { LoginEvent?.Invoke(); }
public LoginViewModel() { _playerManager = new PlayerManager(); LoginCommand = new RelayCommand(param => { Player player = new Player(Username, (param as PasswordBox)?.Password); Player = _playerManager.Login(player); if (null == Player) { MessageBox.Show("There are no players with given credentials in the database", "Login Error", MessageBoxButton.OK); } else { if (null == Player.UserPicture) { player.UserPicture = GetJpgFromImageControl(new BitmapImage(new Uri("../../Images/default.jpg", UriKind.Relative))); Player = _playerManager.Edit(Player.Id, player); } AvatarPath = ByteToImage(Player.UserPicture); LoginEvent?.Invoke(this, EventArgs.Empty); App.CurrentApp.MainViewModel.Refresh(); } }, param => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty((param as PasswordBox)?.Password)); ShowRegisterCommand = new RelayCommand(param => { RegisterView registerView = new RegisterView(); registerView.Show(); }); RegisterCommand = new RelayCommand(param => { Player player = new Player(Username, (param as PasswordBox)?.Password) { UserPicture = GetJpgFromImageControl(AvatarPath) }; if (!_playerManager.Register(player)) { MessageBox.Show("Username already in use.\n Please, pick another.", "Register Error", MessageBoxButton.OK); } else { Application.Current.Windows.OfType <RegisterView>().FirstOrDefault()?.Close(); } }); QuitCommand = new RelayCommand(param => { Application.Current.Windows.OfType <RegisterView>().FirstOrDefault()?.Close(); Application.Current.Windows.OfType <EditView>().FirstOrDefault()?.Close(); AvatarPath = ByteToImage(Player.UserPicture); }); EditCommand = new RelayCommand(param => { Player player = new Player(Username, (param as PasswordBox)?.Password) { UserPicture = GetJpgFromImageControl(AvatarPath) }; Player = _playerManager.Edit(Player.Id, player); App.CurrentApp.MainViewModel.Refresh(); Application.Current.Windows.OfType <EditView>().FirstOrDefault()?.Close(); AvatarPath = ByteToImage(Player.UserPicture); }, param => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty((param as PasswordBox)?.Password)); SelectAvatarCommand = new RelayCommand(param => { AvatarPath = GetUserPicture(); }); }
public async Task Login(string PlexKey) { await(LoginEvent?.Invoke(PlexKey) ?? Task.CompletedTask); }
internal void FireLoginEvent() => LoginEvent?.Invoke(this, new LoginEventArgs() { });
public static void OnLoginEvent() { LoginEvent?.Invoke(null); }
internal void FireLoginEvent(Responses.Session.LoginResponse resp) => LoginEvent?.Invoke(this, new LoginEventArgs() { AccessToken = resp.AccessToken, DeviceID = resp.DeviceID, UserID = resp.UserID });