Example #1
0
        public void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                Xmpp.OnMessage     -= XmppOnOnMessage;
                Xmpp.OnError       -= XmppOnOnError;
                Xmpp.OnAuthError   -= Xmpp_OnAuthError;
                Xmpp.OnStreamError -= XmppOnOnStreamError;
                Xmpp.OnAgentStart  -= XmppOnOnAgentStart;
                Xmpp.Close();
                Xmpp = null;
            }
            Xmpp = new XmppClientConnection(AppConfig.Instance.ServerPath);
            ElementFactory.AddElementType("hostgamerequest", "octgn:hostgamerequest", typeof(HostGameRequest));

            Xmpp.RegisterAccount               = false;
            Xmpp.AutoAgents                    = true;
            Xmpp.AutoPresence                  = true;
            Xmpp.AutoRoster                    = true;
            Xmpp.Username                      = AppConfig.Instance.XmppUsername;
            Xmpp.Password                      = AppConfig.Instance.XmppPassword;
            Xmpp.Priority                      = 1;
            Xmpp.OnMessage                    += XmppOnOnMessage;
            Xmpp.OnError                      += XmppOnOnError;
            Xmpp.OnAuthError                  += Xmpp_OnAuthError;
            Xmpp.OnStreamError                += XmppOnOnStreamError;
            Xmpp.KeepAlive                     = true;
            Xmpp.KeepAliveInterval             = 60;
            Xmpp.OnAgentStart                 += XmppOnOnAgentStart;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            Xmpp.Open();
        }
Example #2
0
        private void RebuildXmpp()
        {
            if (this.xmpp != null)
            {
                //    this.xmpp.OnXmppConnectionStateChanged -= this.XmppOnOnXmppConnectionStateChanged;
                this.xmpp.Close();
                //    this.xmpp = null;
            }

            this.DisconnectedBecauseConnectionReplaced = false;
            if (this.xmpp == null)
            {
                this.xmpp = new XmppClientConnection(this.Config.ChatHost);

                ElementFactory.AddElementType("gameitem", "octgn:gameitem", typeof(HostedGameData));
                ElementFactory.AddElementType("hostgamerequest", "octgn:hostgamerequest", typeof(HostGameRequest));
                ElementFactory.AddElementType("invitetogamerequest", "octgn:invitetogamerequest", typeof(InviteToGameRequest));
                this.Notifications         = new List <Notification>();
                this.Friends               = new List <User>();
                this.Ignorees              = new List <User>();
                this.xmpp.OnRegistered    += this.XmppOnOnRegistered;
                this.xmpp.OnRegisterError += this.XmppOnOnRegisterError;
                this.xmpp.OnXmppConnectionStateChanged += this.XmppOnOnXmppConnectionStateChanged;
                this.xmpp.OnLogin       += this.XmppOnOnLogin;
                this.xmpp.OnAuthError   += this.XmppOnOnAuthError;
                this.xmpp.OnRosterItem  += this.XmppOnOnRosterItem;
                this.xmpp.OnRosterEnd   += this.XmppOnOnRosterEnd;
                this.xmpp.OnRosterStart += this.XmppOnOnRosterStart;
                this.xmpp.OnMessage     += this.XmppOnOnMessage;
                this.xmpp.OnPresence    += this.XmppOnPresence;
                this.xmpp.OnAgentItem   += this.XmppOnOnAgentItem;
                this.xmpp.OnIq          += this.XmppOnOnIq;
                this.xmpp.OnReadXml     += this.XmppOnOnReadXml;
                this.xmpp.OnClose       += this.XmppOnOnClose;
                this.xmpp.OnWriteXml    += this.XmppOnOnWriteXml;
                this.xmpp.OnError       += this.XmppOnOnError;
                this.xmpp.OnSocketError += this.XmppOnOnSocketError;
                this.xmpp.OnStreamError += this.XmppOnOnStreamError;
            }
            if (this.Chatting == null)
            {
                this.Chatting = new Chat(this, this.xmpp);
            }
            else
            {
                this.Chatting.Reconnect(this, this.xmpp);
            }
            if (this.Matchmaking == null)
            {
                this.Matchmaking = new MatchmakingCog(this, this.xmpp);
            }
            //else
            //    this.Matchmaking.Reconnect(this, this.xmpp);
            this.IsConnected           = false;
            this.myPresence            = new Presence();
            this.CurrentHostedGamePort = -1;
            //this.games = new List<HostedGameData>();
        }
Example #3
0
        public MatchmakingBot()
            : base(AppConfig.Instance.ServerPath, AppConfig.Instance.XmppUsername, AppConfig.Instance.XmppPassword)
        {
            ElementFactory.AddElementType("gameitem", "octgn:gameitem", typeof(HostedGameData));
            Messanger.Map <StartMatchmakingRequest>(StartMatchmakingMessage);
            Messanger.Map <MatchmakingLeaveQueueMessage>(LeaveMatchmakingQueueMessage);

            Queue           = new List <MatchmakingQueue>();
            _timer          = new Timer(2000);
            _timer.Elapsed += TimerOnElapsed;
            _timer.Start();
        }
Example #4
0
        public static void Register()
        {
            if (isRegistered)
            {
                return;
            }
            isRegistered = true;

            ElementFactory.AddElementType("acked", agsXMPP.Uri.MSG_RECEIPT, typeof(Easemob.XmppWebSocket.Protocol.Acked));
            ElementFactory.AddElementType("received", agsXMPP.Uri.MSG_RECEIPT, typeof(Easemob.XmppWebSocket.Protocol.Received));
            ElementFactory.AddElementType("delay", "urn:xmpp:delay", typeof(Easemob.XmppWebSocket.Protocol.WSDelay));

            //AddElementType("message", Uri.CLIENT, typeof(agsXMPP.protocol.client.Message));
            ElementFactory.AddElementType("message", agsXMPP.Uri.CLIENT, typeof(Easemob.XmppWebSocket.Protocol.WSMessage));
        }
Example #5
0
        private void RebuildXmpp()
        {
            if (this.xmpp != null)
            {
                //    this.xmpp.OnXmppConnectionStateChanged -= this.XmppOnOnXmppConnectionStateChanged;
                this.xmpp.Close();
                //    this.xmpp = null;
            }

            this.DisconnectedBecauseConnectionReplaced = false;
            if (this.xmpp == null)
            {
                this.xmpp     = new XmppClientConnection(Host);
                this.Chatting = new Chat(this, this.xmpp);
                ElementFactory.AddElementType("gameitem", "octgn:gameitem", typeof(HostedGameData));
                ElementFactory.AddElementType("sub", "octgn:sub", typeof(Sub));
                this.Notifications         = new List <Notification>();
                this.Friends               = new List <User>();
                this.xmpp.OnRegistered    += this.XmppOnOnRegistered;
                this.xmpp.OnRegisterError += this.XmppOnOnRegisterError;
                this.xmpp.OnXmppConnectionStateChanged += this.XmppOnOnXmppConnectionStateChanged;
                this.xmpp.OnLogin          += this.XmppOnOnLogin;
                this.xmpp.OnAuthError      += this.XmppOnOnAuthError;
                this.xmpp.OnRosterItem     += this.XmppOnOnRosterItem;
                this.xmpp.OnRosterEnd      += this.XmppOnOnRosterEnd;
                this.xmpp.OnRosterStart    += this.XmppOnOnRosterStart;
                this.xmpp.OnMessage        += this.XmppOnOnMessage;
                this.xmpp.OnPresence       += this.XmppOnPresence;
                this.xmpp.OnAgentItem      += this.XmppOnOnAgentItem;
                this.xmpp.OnIq             += this.XmppOnOnIq;
                this.xmpp.OnReadXml        += this.XmppOnOnReadXml;
                this.xmpp.OnClose          += this.XmppOnOnClose;
                this.xmpp.OnWriteXml       += this.XmppOnOnWriteXml;
                this.xmpp.OnError          += this.XmppOnOnError;
                this.xmpp.OnSocketError    += this.XmppOnOnSocketError;
                this.xmpp.OnStreamError    += this.XmppOnOnStreamError;
                this.xmpp.OnReadSocketData += this.XmppOnOnReadSocketData;
            }
            this.IsConnected           = false;
            this.myPresence            = new Presence();
            this.CurrentHostedGamePort = -1;
            this.games = new List <HostedGameData>();
        }