예제 #1
0
        /// AccountViewModel Constructor
        /// <summary>
        /// </summary>
        /// <param name="account">The Account passed by the MainWindowViewModel</param>
        public AccountViewModel(BnetAccount account)
        {
            bnetAccount = account;

            // Initialize our BnetViewModel with the BnetAccount
            // Note: Strong VM coupling is discouraged, but it makes sense here
            bnetViewModel = new BnetViewModel(bnetAccount);
        }
예제 #2
0
        public BnetConnection(BnetAccount account, Guid token)
        {
            botAccount = account;

            var server = "useast.battle.net";

            if (botAccount.Server == BnetServer.UsWest)
                server = "uswest.battle.net";
            else if (botAccount.Server == BnetServer.Europe)
                server = "europe.battle.net";
            else if (botAccount.Server == BnetServer.Asia)
                server = "asia.battle.net";

            RemoteEndPoint = new DnsEndPoint(server, 6112);
            connectionToken = token;
            eventTimer = new Timer(eventTimer_Tick);
            eventTimer.Change(300, 0);
        }
예제 #3
0
        public BnetConnection(BnetAccount account, Guid token)
        {
            botAccount = account;

            var server = "useast.battle.net";

            if (botAccount.Server == BnetServer.UsWest)
            {
                server = "uswest.battle.net";
            }
            else if (botAccount.Server == BnetServer.Europe)
            {
                server = "europe.battle.net";
            }
            else if (botAccount.Server == BnetServer.Asia)
            {
                server = "asia.battle.net";
            }

            RemoteEndPoint  = new DnsEndPoint(server, 6112);
            connectionToken = token;
            eventTimer      = new Timer(eventTimer_Tick);
            eventTimer.Change(300, 0);
        }
예제 #4
0
        /// <summary>
        /// BnetViewModel's constructor
        /// </summary>
        /// <param name="account">BnetAccount passed by AccountViewModel</param>
        public BnetViewModel(BnetAccount account)
        {
            ChatMessages = new ObservableCollection<BnetEvent>();
            ChannelList = new ObservableCollection<BnetUser>();
            ChannelUsers = new ObservableCollection<BnetUser>();
            FriendsList = new ObservableCollection<BnetFriend>();
            AutoCompletionEntries = new ObservableCollection<AutoCompletionEntry>();
            AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Reply Command", Description = "Replies to the last person who whispered you.", LiteralText = "/r" });
            AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Reconnect Command", Description = "Reconnects the current account to Battle.net.", LiteralText = "/reconnect" });
            AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Version Command", Description = "Emotes the current bot version.", LiteralText = "/version" });

            ChattingStatus = "disconnected";
            // Initialize Battle.net stuff
            bnetAccount = account;

            // Start listening for messages from BnetConnection
            Messenger.Default.Register<BnetEvent[]>(this, token, BnetEventReceived);
            Messenger.Default.Register<BnetFriend>(this, token, BnetFriendReceived);

            Connect();
        }