void _WelcomeWindow_NewGame(XmlLobbyState lobby) { _MapCreatorMain.Visibility = Visibility.Hidden; ucLobby.Visibility = Visibility.Visible; ucLobby.LobbyState = lobby; _TestGameMain.Visibility = Visibility.Hidden; //_GameMain.Login(user, pass); this.BringIntoView(); _WelcomeWindow.WindowState = WindowState.Minimized; }
/// <summary> /// Takes a <see cref="Common.Person">Person</see> and allows them /// to join the chat room, if there is not already a chatter with /// the same name /// </summary> /// <param name="person"><see cref="Common.Person">Person</see> joining</param> /// <returns>An array of <see cref="Common.Person">Person</see> objects</returns> public JoinResult Join(XmlUserCredentials person) { MessageFromServerAction message = new MessageFromServerAction(); message.Sender = _ServerUser.ID; if (person == null) { message.Message = "No valid person passed (Usercredentials object == null)"; return new JoinResult() { FailMessage = message }; } if (String.IsNullOrEmpty(person.Name) || String.IsNullOrEmpty(person.Password)) { message.Message = "either password or username isnt valid: empty password or username"; return new JoinResult() { FailMessage = message }; } /* XmlUser user = _UserAdministration.Authenticate(person); // we failed to authenticate, communicate this back to user if (user == null) { message.Message = "either password or username isnt valid, or both"; return new JoinResult() { FailMessage = message }; } */ //Yey! we are authenticated. Add user to list of users and // return the lobby state bool userAdded = false; //create a new ChatEventHandler delegate, pointing to the MyEventHandler() method myEventHandler = new GameEventHandler(MyEventHandler); //carry out a critical section that checks to see if the new chatter //name is already in use, if its not allow the new chatter to be //added to the list of chatters, using the person as the key, and the //ChatEventHandler delegate as the value, for later invocation lock (threadSync) { /* if (!PlayerExists(user.ID)) { _Users.Add(user, MyEventHandler); userAdded = true; _CurrentPerson = user; } else { message.Message = "It seems that you are already logged in."; return new JoinResult() { FailMessage = message }; } */ } //if the new chatter could be successfully added, get a callback instance //create a new message, and broadcast it to all other chatters, and then //return the list of al chatters such that connected clients may show a //list of all the chatters if (userAdded) { _Callback = OperationContext.Current.GetCallbackChannel<IChatCallback>(); //add this newly joined chatters ChatEventHandler delegate, to the global //multicast delegate for invocation ChatEvent += myEventHandler; XmlLobbyState lobbyState = new XmlLobbyState(); //carry out a critical section that copy all chatters to a new list lock (threadSync) { //copy chatlog if (_LobbyChatLog != null) { lobbyState.LobbyChat = _LobbyChatLog.Copy(); } //copy users if (_Users != null) { lobbyState.Users = new List<XmlUser>(); foreach (KeyValuePair<XmlUser, GameEventHandler> lobbyUser in _Users) lobbyState.Users.Add(lobbyUser.Key.Copy()); } //copy games if (_Games != null) { lobbyState.Games = CreateGameList(); } } /* //Say to all other players we have a new player joined in the lobby LobbyJoinedAction lobbyJoined = new LobbyJoinedAction() { NewPlayer = user, Sender = _ServerUser.ID }; BroadcastMessage(lobbyJoined, user); return new JoinResult() { User = user, LobbyState = lobbyState }; */ return null; } else { message.Message = "You are already in the list of logged in players!"; message.Sender = _ServerUser.ID; return null; } }
public void Login(XmlLobbyState lobby) { }
private void OnLobbyJoined(XmlLobbyState lobby) { if (LobbyJoined != null) { spCredentials.Visibility = Visibility.Collapsed; LobbyJoined(lobby); } }