public LoginCommand(UserInfo userInfo) : base(CommandType.Login) { Contract.Requires(userInfo != null); UserInfo = userInfo; }
public UserStateCommand(UserInfo userInfo, string userState) : base(CommandType.UserState) { Contract.Requires(userInfo != null); Contract.Requires(userState != null); UserInfo = userInfo; UserState = userState; }
public TextMessageCommand(UserInfo from, UserInfo to, string message) : base(CommandType.TextMessage) { Contract.Requires(from != null); Contract.Requires(to != null); Contract.Requires(message != null); From = from; To = to; Message = message; }
/// <summary> /// Static helper method that reads command from dynamic xml wrapper. /// </summary> private static Command ReadCommand(CommandType commandType, dynamic dynamicElement) { switch (commandType) { case CommandType.Login: { string name = dynamicElement.command.userInfo.name; var userInfo = new UserInfo(name); return new LoginCommand(userInfo); ; } case CommandType.Ack: long messageId = dynamicElement.command.messageId; return new AckCommand(messageId); case CommandType.UserState: { string userName = dynamicElement.command.userInfo.name; var userInfo = new UserInfo(userName); string userState = dynamicElement.command.userState; return new UserStateCommand(userInfo, userState); } case CommandType.TextMessage: { string from = dynamicElement.command.from.userInfo.name; string to = dynamicElement.command.to.userInfo.name; string message = dynamicElement.command.textMessage; return new TextMessageCommand(new UserInfo(from), new UserInfo(to), message); } break; default: throw new InvalidOperationException("Unsupported command type: " + commandType); } }
public FullUserInfo(UserInfo userInfo) { Contract.Requires(userInfo != null); UserInfo = userInfo; UserState = "Disconnected"; }