Exemplo n.º 1
0
        private Communicator(string name, string serverIp, int port)
        {
            tcpConnector = new TcpConnector(name, "asdasdasd", serverIp, port);

            #region TcpConnector events subscription
            tcpConnector.waitingForOpponent += tcpConnector_waitingForOpponent;
            tcpConnector.gameStarted += tcpConnector_gameStarted;
            tcpConnector.messageRecieved += TcpConnector_messageRecieved;
            tcpConnector.opponentDisconnected += TcpConnector_opponentDisconnected;
            #endregion

            #region GameEventManager events subscription
            GameEventManager.throwDice += GameEventManager_throwDice;
            GameEventManager.loadXmlForBibliotheca += GameEventManager_loadXmlForBibliotheca;
            GameEventManager.sendOpponentName += GameEventManager_SendOpponentName;
            GameEventManager.endRoud += GameEventManager_endRound;
            GameEventManager.playCard += GameEventManager_playCard;
            GameEventManager.canPlayCard += GameEventManager_CanPlayCard;
            GameEventManager.idTarget += GameEventManager_idTarget;
            GameEventManager.unityReady += GameEventManager_unityReady;
            GameEventManager.manaChosen += GameEventManager_manaChosen;
            GameEventManager.createPool += GameEventManager_createPool;
            GameEventManager.canCreateManaPool += GameEventManager_canCreateManaPool;
            GameEventManager.menuRequest += GameEventManager_menuRequest;
            #endregion

            tcpConnector.Connect();
        }
 public XmppMessageManager(TcpConnector tc, string nickname, string password, string partner)
 {
     this.nickname = nickname;
     this.password = password;
     this.partner = partner;
     this.tcpConnector = tc;
     this.uniqueMessageId = 0;
     messagesQueue = new LinkedList<KeyValuePair<string,string>>();
     loginSasl = XmlGenericMessages.Base64Encode("\0"+nickname+"\0"+password);
     messagesQueue.AddLast(new KeyValuePair<string, string>(XmlGenericMessages.OpenStream, "features>"));
     messagesQueue.AddLast(new KeyValuePair<string, string>(loginSasl, "\"/>"));
     messagesQueue.AddLast(new KeyValuePair<string, string>(XmlGenericMessages.ResourceSetup,"</iq>"));
     messagesQueue.AddLast(new KeyValuePair<string, string>(XmlGenericMessages.OpenSessionRequest,">"));
     messagesQueue.AddLast(new KeyValuePair<string, string>(XmlGenericMessages.PresenceNotify,"/presence>"));
     messagesQueue.AddLast(new KeyValuePair<string, string>(XmlGenericMessages.FindRooms,"/iq>"));
     tcpConnector.sendServerMessage(messagesQueue.First.Value);
     messagesQueue.RemoveFirst();
 }