コード例 #1
0
        public LoginCommand(UserInfo userInfo)
            : base(CommandType.Login)
        {
            Contract.Requires(userInfo != null);

            UserInfo = userInfo;
        }
コード例 #2
0
        public UserStateCommand(UserInfo userInfo, string userState)
            : base(CommandType.UserState)
        {
            Contract.Requires(userInfo != null);
            Contract.Requires(userState != null);

            UserInfo = userInfo;
            UserState = userState;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
ファイル: Server.cs プロジェクト: SergeyTeplyakov/CrazyTalk
            public FullUserInfo(UserInfo userInfo)
            {
                Contract.Requires(userInfo != null);
                UserInfo = userInfo;

                UserState = "Disconnected";
            }