private static void HandleClientCommunication(User userObj, string userInput) { UserInput CurrentInput = new UserInput(userObj, userInput); if (userInput.StartsWith(".")) { if (userInput.Trim().Length == 1) { userObj.LastCommand.Run(userObj.LastInput); return; } //TODO: need to check partial input as well ICommand CurrentCommand = Server.CommandList.Find(x => x.Name.Equals(CurrentInput.Args [0].ToLower())); if (CurrentCommand != null) { userObj.LastCommand = CurrentCommand; userObj.LastInput = CurrentInput; CurrentCommand.Run(CurrentInput); } else { userObj.WriteLine("Unknown command."); } } else { //TODO: setup default command thing.. Server.DefaultCommand.Run(CurrentInput); } }
private static void ConnectUser(User UserObj, IUserConnection userConnection) { UserObj.Logon = DateTime.UtcNow; UserObj.Room = Server.LoginRoom; UserObj.Room.Users.Add(UserObj); Server.ClientList.Add(UserObj); List<User> WriteAllButUsers = new List<User>(); Server.ClientList.ForEach(delegate(User currentUser) { if(currentUser.Ignores.HasFlag(User.Ignore.Logons) || currentUser.Ignores.HasFlag(User.Ignore.All)) { WriteAllButUsers.Add(currentUser); } }); Server.CommandList.ForEach(delegate(ICommand command) { if(command.Name.Equals("look")) { UserInput newInput = new UserInput(UserObj, "look"); command.Run(newInput); } }); Server.WriteAllBut("[Entering is: " + UserObj.Name + " " + UserObj.Desc + " ] \n", WriteAllButUsers); }
public void ChangeRoom(Room newRoom) { //take the user out of the room so that write to room is faster. this.Room.Users.Remove(this); this.Room = newRoom; this.Room.Users.Add(this); //TODO: find a better way to do this Server.CommandList.ForEach(delegate(ICommand command) { if(command.Name.Equals("look")) { UserInput newInput = new UserInput(this, "look"); command.Run(newInput); } }); }