void LoginQuery(Messenger messenger, string key, LoginQuery query) { try { try { using (var account = new StreamReader(new FileStream(accountPath + "\\" + query.id, FileMode.Open))) { var pw = account.ReadLine(); var name = account.ReadLine(); if (query.pw == pw) { messenger.Send("Login", new LoginAnswer(query.confirmID, true, name, "Town")); } else { throw new InvalidLoginException("PW가 다릅니다."); } } } catch (IOException) { throw new InvalidLoginException("존재하지 않는 ID입니다."); } } catch (InvalidLoginException e) { var answer = new LoginAnswer(query.confirmID, false, "", ""); answer.message = e.message; messenger.Send("Login", answer); } }
void LoginAnswer(Messenger messenger, string key, LoginAnswer query) { if (query.accepted) { var keys = (ICollection<string>)_server._clientMessenger.Keys; if (keys.Contains(query.name)) { query.accepted = false; _server._confirmMessenger.Send(query.confirmID.ToString(), query); } else { lock (_server._lock) { PacketStream stream = _server._confirmMessenger.Unregister(query.confirmID.ToString()); _server._clientMessenger.Register(query.name, stream); } _server._clientMessenger.Send(query.name, query); //_server._messenger.Send(query.world, new PlayerJoin()); } } else { _server._confirmMessenger.Send(query.confirmID.ToString(), query); } }
void LoginAnswer(Messenger messenger, string key, LoginAnswer answer) { //If failed, Show Failed Message. if (answer.accepted) { SceneManager.LoadScene(answer.world); userName = answer.name; var net = FindObjectOfType<Client>(); lock (_locker) net.stream = messenger.Unregister("Proxy"); userName = answer.name; net.signallersByID = signallersByID; net.enabled = true; } else { onLoginFailed(answer.message); } }
void LoginAnswer(Messenger messenger, string key, LoginAnswer query) { messenger.Send("Proxy", query); }
void LoginAnswer(Messenger messenger, string key, LoginAnswer answer) { if (answer.accepted) { if (IsLoggedIn(answer.name)) { answer.accepted = false; answer.message = "이미 로그인 중입니다."; _confirmMessenger.Send(answer.confirmID.ToString(), answer); } else { try { lock (_lock) { PacketStream stream = _confirmMessenger.Unregister(answer.confirmID.ToString()); AddClient(answer.name, stream); } try { _worldByUser.Add(answer.name, answer.world); } catch (ArgumentException e) { History.Log(e.ToString()); _worldByUser[answer.name] = answer.world; } _messenger.Send(answer.name, answer); } catch(Exception e) { History.Log(e.ToString()); } } } else { _confirmMessenger.Send(answer.confirmID.ToString(), answer); } }