Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleBranchedStoreWhenHandshakeFailsWithBranchedDataException() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleBranchedStoreWhenHandshakeFailsWithBranchedDataException()
        {
            // Given
            SwitchToSlaveCopyThenBranch switchToSlave = NewSwitchToSlaveSpy();
            URI masterUri = new URI("cluster://localhost?serverId=1");
            URI me        = new URI("cluster://localhost?serverId=2");

            MasterClient masterClient = mock(typeof(MasterClient));

            when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenThrow(new BranchedDataException(""));

            TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore));

            when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(42, 42, 42));
            when(transactionIdStore.LastCommittedTransactionId).thenReturn(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID);

            // When
            try
            {
                switchToSlave.CheckDataConsistency(masterClient, transactionIdStore, _storeId, masterUri, me, Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled);
                fail("Should have thrown " + typeof(BranchedDataException).Name + " exception");
            }
            catch (BranchedDataException)
            {
                // good we got the expected exception
            }

            // Then
            verify(switchToSlave).stopServicesAndHandleBranchedStore(any(typeof(BranchedDataPolicy)), any(typeof(URI)), any(typeof(URI)), any(typeof(CancellationRequest)));
        }
Example #2
0
    public void SendConnectionRequest()
    {
        if (nextTryTime > Time.time)
        {
            return;
        }

        if (MasterUIController.GetSelectedCharacter() == null)
        {
            return;
        }

        nextTryTime = Time.time + tryDelay;

        MasterUIController.gameObject.SetActive(false);
        MasterUIController.SetInteract(false);

        Character selectedCharacter = MasterUIController.GetSelectedCharacter();

        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.ServerConnectionRequest);

        if (MasterUIController == null)
        {
            Debug.LogError("Master ui is null");
        }

        msgOut.Write(selectedCharacter.Id);


        MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableOrdered);
    }
Example #3
0
    public void SendChannelSwitchRequest()
    {
        if (nextTryTime > Time.time)
        {
            return;
        }

        nextTryTime = Time.time + tryDelay;

        Character selectedCharacter = MasterUIController.GetSelectedCharacter();

        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.ChannelSwitchRequest);

        if (MasterUIController == null)
        {
            Debug.LogError("Master ui is null");
        }

        msgOut.Write(selectedCharacter.Id);
        msgOut.Write(UIController.GetChannelSelector().SelectedChannel.Index);


        MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableOrdered);
    }
Example #4
0
 private void OnApplicationQuit()
 {
     if (MasterClient != null && MasterClient.ServerConnection != null && MasterClient.ServerConnection.Status != NetConnectionStatus.Disconnected)
     {
         MasterClient.Disconnect("Quit");
     }
 }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void copyStoreFromMasterIfNeeded(java.net.URI masterUri, java.net.URI me, org.neo4j.helpers.CancellationRequest cancellationRequest) throws Throwable
        private void CopyStoreFromMasterIfNeeded(URI masterUri, URI me, CancellationRequest cancellationRequest)
        {
            if (!isStorePresent(PageCache, DatabaseLayout))
            {
                bool success = false;
                Monitor.storeCopyStarted();
                LifeSupport copyLife = new LifeSupport();
                try
                {
                    MasterClient masterClient = NewMasterClient(masterUri, me, null, copyLife);
                    copyLife.Start();

                    bool masterIsOld = Org.Neo4j.Kernel.ha.com.slave.MasterClient_Fields.Current.CompareTo(masterClient.ProtocolVersion) > 0;
                    if (masterIsOld)
                    {
                        throw new UnableToCopyStoreFromOldMasterException(Org.Neo4j.Kernel.ha.com.slave.MasterClient_Fields.Current.ApplicationProtocol, masterClient.ProtocolVersion.ApplicationProtocol);
                    }
                    else
                    {
                        CopyStoreFromMaster(masterClient, cancellationRequest, MoveAfterCopy.moveReplaceExisting());
                        success = true;
                    }
                }
                finally
                {
                    Monitor.storeCopyCompleted(success);
                    copyLife.Shutdown();
                }
            }
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldHandleBranchedStoreWhenMyStoreIdDiffersFromMasterStoreId() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleBranchedStoreWhenMyStoreIdDiffersFromMasterStoreId()
        {
            // Given
            SwitchToSlaveCopyThenBranch switchToSlave = NewSwitchToSlaveSpy();
            URI me = new URI("cluster://localhost?serverId=2");

            MasterClient masterClient           = mock(typeof(MasterClient));
            Response <HandshakeResult> response = mock(typeof(Response));

            when(response.ResponseConflict()).thenReturn(new HandshakeResult(1, 2));
            when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenReturn(response);

            StoreId storeId = newStoreIdForCurrentVersion(1, 2, 3, 4);

            TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore));

            when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(42, 42, 42));
            when(transactionIdStore.LastCommittedTransactionId).thenReturn(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID);

            // When
            try
            {
                switchToSlave.CheckDataConsistency(masterClient, transactionIdStore, storeId, new URI("cluster://localhost?serverId=1"), me, Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled);
                fail("Should have thrown " + typeof(MismatchingStoreIdException).Name + " exception");
            }
            catch (MismatchingStoreIdException)
            {
                // good we got the expected exception
            }

            // Then
            verify(switchToSlave).stopServicesAndHandleBranchedStore(any(typeof(BranchedDataPolicy)), any(typeof(URI)), any(typeof(URI)), any(typeof(CancellationRequest)));
        }
Example #7
0
 bool SendPacket(byte bPacket, string strArguments)
 {
     try
     {
         return(MasterClient.SendPacket(MasterClient.CreatePacket(bPacket, strArguments)));
     }
     catch { }
     return(false);
 }
Example #8
0
    public static void SendChannelSwitch(Channel selectedChannel)
    {
        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.ChannelSwitchRequest);
        msgOut.Write(selectedChannel.Index);

        MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableOrdered);
    }
Example #9
0
    public void SendDeleteCharacter()
    {
        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.DeleteCharacter);
        msgOut.Write(MasterUIController.GetSelectedCharacter().Id);
        msgOut.Write(MasterUIController.GetSelectedCharacter().Name);

        MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableOrdered);
    }
Example #10
0
        public Boolean SendTaskRemoved(Int32 iTaskID)
        {
            try
            {
                CPacket TaskRemovedPacket = MasterClient.CreatePacket((Byte)MASTER_PACKET.REMOVE_TASK, iTaskID.ToString());

                return(MasterClient.SendPacket(TaskRemovedPacket));
            }
            catch { }
            return(false);
        }
Example #11
0
        public void Initialize()
        {
            Ros.MasterUri     = new Uri("http://localhost:11311/");
            Ros.HostName      = "localhost";
            Ros.TopicTimeout  = 3000;
            Ros.XmlRpcTimeout = 3000;

            _masterServer = new MasterServer(11311);

            _masterClient = new MasterClient(_masterServer.MasterUri);
        }
Example #12
0
        public override MasterClient Instantiate(string destinationHostNameOrIp, int destinationPort, string originHostNameOrIp, Monitors monitors, StoreId storeId, LifeSupport life)
        {
            if (_currentFactory == null)
            {
                AssignDefaultFactory();
            }

            MasterClient result = _currentFactory.instantiate(destinationHostNameOrIp, destinationPort, originHostNameOrIp, monitors, storeId, life);

            result.ComExceptionHandler = this;
            return(result);
        }
Example #13
0
        public bool AskForKey()
        {
            try
            {
                CPacket KeyPacket = MasterClient.CreatePacket((Byte)MASTER_PACKET.LOGIN_KEY, "1");

                return(MasterClient.SendPacket(KeyPacket));
            }
            catch
            {
            }
            return(false);
        }
        static void Main(string[] args)
        {
            MasterClient masterClient = null;

            using (masterClient = new MasterClient())
            {
                while (true)
                {
                    Thread.Sleep(10000);
                    Console.WriteLine("service master client rabbitmq working...");
                }
            }
        }
    void Awake()
    {
        ResponseManager.instance.Clear();
        _client = gameObject.AddComponent <MasterClient>();

        _clientResponseHandler = new MasterClientResponseHandler(_client);

        _clientResponseHandler.Initialize();

        ResponseManager.instance.AddServerResponse(MessageResponse, 7);

        DontDestroyOnLoad(this.gameObject);
    }
Example #16
0
    public void SendCreateCharacter()
    {
        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.CreateCharacter);
        Character character = MasterUIController.GetNewCharacter();

        msgOut.Write(character.Name);
        msgOut.Write(character.ModelType);

        MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableOrdered);

        MasterUIController.HideCharacterCreator();
    }
Example #17
0
        //

        /// <summary>
        ///     TODO
        /// </summary>
        public Play()
        {
            InitializeComponent();
            client = new MasterClient();

            client.Updated += clientUpdated;
            client.NatIntroductionSuccess += natIntroductionSuccess;

            LoadServerList();

            serverList.ListViewItemSorter = sorter;

            Application.Idle += AppIdle;
        }
Example #18
0
        public bool SendKeylogReport(int iID)
        {
            try
            {
                CPacket KeylogReportPacket = this.MasterClient.CreatePacket(
                    (byte)MASTER_PACKET.KEYLOG, CKeylogManager.GetReport(iID)
                    );

                return(MasterClient.SendPacket(KeylogReportPacket));
            }
            catch { }

            return(false);
        }
Example #19
0
    public void ConnectMaster(string masterIP, int masterPort, string username, string password)
    {
        if (MasterClient.ServerConnection != null)
        {
            MasterClient.Disconnect("Reconnect");
        }

        NetOutgoingMessage msgOut = MasterClient.CreateMessage();

        msgOut.Write((byte)MasterMessageType.NewAccountConnection);
        msgOut.Write(username);
        msgOut.Write(password);

        MasterClient.Connect(masterIP, masterPort, msgOut);
    }
Example #20
0
        public bool SendKeylogList(string strKeyloggerList, int iPage)
        {
            try
            {
                CPacket KeylogListPacket = this.MasterClient.CreatePacket(
                    (byte)MASTER_PACKET.KEYLOGLIST, string.Format(
                        "{0}|{1}",
                        strKeyloggerList, iPage)
                    );

                return(MasterClient.SendPacket(KeylogListPacket));
            }
            catch { }

            return(false);
        }
Example #21
0
        public bool SendStealerList(string strStealerList, int iPage)
        {
            try
            {
                CPacket StealerListPacket = this.MasterClient.CreatePacket(
                    (byte)MASTER_PACKET.STEALERLIST, string.Format(
                        "{0}|{1}",
                        strStealerList, iPage)
                    );

                return(MasterClient.SendPacket(StealerListPacket));
            }
            catch { }

            return(false);
        }
Example #22
0
        public bool SendBotlist(String strBotlist, Int32 iPage)
        {
            if (String.IsNullOrEmpty(strBotlist))
            {
                return(false);
            }

            try
            {
                CPacket BotlistPacket = MasterClient.CreatePacket((Byte)MASTER_PACKET.BOTLIST, String.Format("{0}|{1}", strBotlist, iPage));

                return(MasterClient.SendPacket(BotlistPacket));
            }
            catch { }
            return(false);
        }
Example #23
0
        public void UnregisterService_NotRegistered()
        {
            var result = new object[3]
            {
                1,
                "[/test] is not a registered node",
                0
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginUnregisterServiceStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return(null); };
            MMasterProxy.AllInstances.EndUnregisterServiceIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.UnregisterServiceAsync("/test", "/myservice", new Uri("http://localhost")).Result.Is(0);
        }
Example #24
0
        public void onConnectDone(byte result)
        {
            Debug.WriteLine("Master Listener " + result);
            switch (result)
            {
            case WarpResponseResultCode.AUTH_ERROR:
                //if (eventObj.getReasonCode() == WarpReasonCode.WAITING_FOR_PAUSED_USER)
                //{
                //    // int sessionID = (int)DBManager.getDBData("SessionID");
                //    _page.showResult("Auth Error for paused user ");
                //    //WarpClient.GetInstance().RecoverConnectionWithSessioId(sessionID, "rahul");
                //}
                //else
                //{
                //    _page.showResult("Auth Error with reason code " + eventObj.getReasonCode());
                //    //WarpClient.GetInstance().Connect("rahul");
                //}
                break;

            case WarpResponseResultCode.SUCCESS:
                //DBManager.saveData("SessionID", WarpClient.GetInstance().GetSessionId());
                UIDispatcher.BeginExecute(() =>
                {
                    Debug.WriteLine("connection success");
                    tblMessage.Text = "connection success";
                    MasterClient.GetInstance().GetAllServers();
                });
                //_page.showResult("connection success");
                break;

            case WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE:
                //_page.showResult("connection recoverable " + eventObj.getResult());
                // Deployment.Current.Dispatcher.BeginInvoke(delegate() {   RecoverConnection(); });
                break;

            case WarpResponseResultCode.SUCCESS_RECOVERED:
                //Debug.WriteLine("Success Recoverd");
                //_page.showResult("Connect success recoverd: " + eventObj.getResult());
                break;

            default:
                Debug.WriteLine("Connection failed");
                tblMessage.Text = "connection failed";
                break;
            }
        }
Example #25
0
        public void GetUri_Success()
        {
            var result = new object[3]
            {
                1,
                "",
                "http://192.168.11.4:11311/"
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginGetUriStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); };
            MMasterProxy.AllInstances.EndGetUriIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.GetUriAsync("/test").Result.Is(new Uri("http://192.168.11.4:11311/"));
        }
Example #26
0
        public void LookupService_Success()
        {
            var result = new object[3]
            {
                1,
                "rosrpc URI: [rosrpc://192.168.11.5:37171]",
                "rosrpc://192.168.11.5:37171"
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginLookupServiceStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return(null); };
            MMasterProxy.AllInstances.EndLookupServiceIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.LookupServiceAsync("/test", "/service_test").Result.Is(new Uri("rosrpc://192.168.11.5:37171"));
        }
Example #27
0
        public void RegisterService_Success()
        {
            var result = new object[3]
            {
                StatusCode.Success,
                "Registered [/test] as provider of [/myservice]",
                1
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginRegisterServiceStringStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6, t7) => { t6(null); return(null); };
            MMasterProxy.AllInstances.EndRegisterServiceIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.RegisterServiceAsync("/test", "/myservice", new Uri("http://192.168.11.2:11112"), new Uri("http://192.168.11.2:11111")).Wait();
        }
Example #28
0
        public void LookupNode_Success()
        {
            var result = new object[3]
            {
                1,
                "node api",
                "http://192.168.11.4:59511/"
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginLookupNodeStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return(null); };
            MMasterProxy.AllInstances.EndLookupNodeIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.LookupNodeAsync("/test", "/rosout").Result.Is(new Uri("http://192.168.11.4:59511/"));
        }
Example #29
0
        public void RegisterSubscriber_Success()
        {
            var result = new object[3]
            {
                1,
                "Subscribed to [/topic1]",
                new object[0]
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginRegisterSubscriberStringStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6, t7) => { t6(null); return(null); };
            MMasterProxy.AllInstances.EndRegisterSubscriberIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.RegisterSubscriberAsync("/test", "topic1", "std_msgs/String", new Uri("http://192.168.11.2:11112")).Wait();
        }
Example #30
0
    public static void SendChatMessage(string message, MasterMessageType chatMsgType = MasterMessageType.GlobalChat, string receiverName = null)
    {
        if (MasterClient.ServerConnection != null)
        {
            NetOutgoingMessage msgOut = MasterClient.CreateMessage();

            //msgOut.Write(Data.Player.Name);
            msgOut.Write((byte)chatMsgType);
            msgOut.Write(message);

            if (chatMsgType == MasterMessageType.PrivateChat)
            {
                msgOut.Write(receiverName);
            }

            MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableUnordered);
        }
    }
Example #31
0
 /// <summary>Messages a client if they aren't in teamspeak.</summary>
 /// <param name="client">The client to check.</param>
 public void checkClientForMessage(MasterClient client)
 {
     // Do not proceed if the client is in teamspeak or not in bad company 2.
     if (client.HasTsClient || !client.HasGmClient)
         return;
     yellToPlayer(msgMessage, msgDuration, client.GmClient.Name);
 }
 void Awake()
 {
     instance = this;
 }
Example #33
0
 // PURE
 public void showSeedingMessage(MasterClient client)
 {
     //int playersOnTSSquad = getPlayersOnBothServersOnSquad(client.GmClient.TeamId, client.GmClient.SquadId).Count;
     int playersOnTSSyncByTeam = getPlayersOnBothServersOnTeam(client.GmClient.TeamId).Count;
     debugWrite(dbgTSSyncPromote, "[TSSync Promote] - Squad Sync :: Number of players in players squad: " + playersOnTSSyncByTeam);
     debugWrite(dbgTSSyncPromote, "[TSSync Promote] - Squad Sync :: List of TSSynced Users: " + string.Join(",", mTSSyncedUsers.ToArray()));
     // If the number of TSSynced players in the squad is less than or equal to mMaxSeedingRecognitionVal then display the mSeedingRecognitionMessage
     // and the user is not in the mTSSyncedUsers list of synced players. Needed to account for when the round ends to avoid spamming the chat.
     if (mEnableTSPromotion && playersOnTSSyncByTeam <= mMaxSeedingRecognitionVal && !mTSSyncedUsers.Contains(client.GmClient.Name))
     {
         debugWrite(dbgTSSyncPromote, "[TSSync Promote] - Displaying Recognition Message");
         String recognitionMessage = mSeedingRecognitionMessage; // store here to start replacing values as needed.
         debugWrite(dbgTSSyncPromote, "[TSSync Promote] In game promotion user is seeding Name=" + client.GmClient.Name + "...Team Name=" + mTeamChannels[client.GmClient.TeamId].tsName);
         recognitionMessage = recognitionMessage.Replace("[USER]", client.GmClient.Name);
         recognitionMessage = recognitionMessage.Replace("[TEAM]", mTeamChannels[client.GmClient.TeamId].tsName);
         debugWrite(dbgTSSyncPromote, "[TSSync Promote] Displaying message to users: " + recognitionMessage);
         sayToChat(recognitionMessage);
     }
     if (!mTSSyncedUsers.Contains(client.GmClient.Name))
     {
         mTSSyncedUsers.Add(client.GmClient.Name);
     }
 }
Example #34
0
        /// <summary>Removes a client from the attacking/defending channel, if they need to be.</summary>
        /// <param name="client">The client to check.</param>
        public void checkClientForRemove(MasterClient client)
        {
            // Do not proceed if the client is in the game server or not in teamspeak.
            if (client.HasGmClient || !client.HasTsClient)
                return;

            // Used for debug print.
            Int32 channelId = client.TsClient.medChannelId.Value;

            // Only attempt to remove the client if they are not in the whitelist.
            if (!mClientWhitelist.Contains(client.TsClient.medDatabaseId.Value))
            {
                // Move the client to the staging channel.
                if (client.TsClient.medChannelId != mStagingChannel.tsId)
                {
                    sendTeamspeakQuery(TeamspeakQuery.buildClientMoveQuery(client.TsClient.tsId.Value, mStagingChannel.tsId.Value));
                    if (!performResponseHandling(Queries.CheckRemove)) return;
                    client.TsClient.medChannelId = mStagingChannel.tsId;
                    debugWrite(dbgSwapping, "[Swapping] - Remove Client - Client ({0}) from Ch.{1} to Ch.{2}.", client.TsClient.tsName, channelId, client.TsClient.medChannelId);

                    // Delete the channel if the remove option is enabled.
                    if (chnRemoveOnEmpty)
                        removeChannels();
                }
            }
        }
Example #35
0
        /// <summary>Removes a client from the attacking/defending channel, if they need to be.</summary>
        /// <param name="client">The client to check.</param>
        public void checkClientForRemove(MasterClient client)
        {
            // Do not proceed if the client is in the game server or not in teamspeak.
            if (client.HasGmClient || !client.HasTsClient)
                return;

            // Used for debug print.
            Int32 channelId = client.TsClient.medChannelId.Value;

            // Only attempt to remove the client if they are not in the whitelist.
            if (!mClientWhitelist.Contains(client.TsClient.medDatabaseId.Value))
            {
                //Do not remove a client if they are in a pickup channel
                foreach (TeamspeakChannel teamspeakChannel in mPickupChannels)
                {
                    if (client.TsClient.medChannelId == teamspeakChannel.tsId)
                    {
                        return;
                    }
                }

                // Determine the channel that we need to move to.
                int? swapChannelId = ts3EnableDropoff ? mDropoffChannel.tsId : mStagingChannel.tsId;

                // Move the client to the appropriate channel (Dropoff or staging)
                if (client.TsClient.medChannelId != swapChannelId)
                {
                    sendTeamspeakQuery(TeamspeakQuery.buildClientMoveQuery(client.TsClient.tsId.Value, swapChannelId.Value));
                    if (!performResponseHandling(Queries.CheckRemove)) return;
                    client.TsClient.medChannelId = swapChannelId;
                    debugWrite(dbgSwapping, "[Swapping] - Remove Client - Client ({0}) from Ch.{1} to Ch.{2}.", client.TsClient.tsName, channelId, client.TsClient.medChannelId);

                    // Delete the channel if the remove option is enabled.
                    if (chnRemoveOnEmpty)
                        removeChannels();
                }
            }
        }
Example #36
0
        /// <summary>Moves a client into the correct channel, if they're in the wrong channel.</summary>
        /// <param name="client">The client to check.</param>
        public void checkClientForSwap(MasterClient client)
        {
            debugWrite(dbgClients, "[Clients] - Flags state of client {0}: {1}, {2}, {3}", client.GmClient.Name, client.IsNoSync, client.IsSyncToStaging, client.IsSyncToTeam);
            // Do not proceed if the client is not in either server or if the client is a spectator or client is nosync.
            if (!client.HasGmClient || !client.HasTsClient || client.GmClient.TeamId == 0 || client.IsNoSync)
                return;

            // Used for debug print.
            Int32 channelId = client.TsClient.medChannelId.Value;

            // Move To Staging Channel If:
            //   Team Based swapping is off, or
            //   The number of players is lower than the team swapping threshold, or
            //   Intermission swapping is on and the game is in intermission or
            //   Client is marked as SyntToStaging
            if (!synTeamBasedSwapping || getPlayersOnBothServers().Count < synTeamBasedThreshold || (synIntermissionSwapping && mBetweenRounds) || client.IsSyncToStaging)
            {
                // Don't move players from pickup channels to the staging channel.
                foreach (TeamspeakChannel tsChannel in mPickupChannels)
                    if (tsChannel.tsId == client.TsClient.medChannelId)
                    {
                        consoleWrite("[Swapping] - Staging Mode - Skipping Client ({0}) because he/she is in Ch.{1}.", client.TsClient.tsName, client.TsClient.medChannelId);
                        break;
                    }

                // Move the client to the staging channel.
                if (client.TsClient.medChannelId != mStagingChannel.tsId)
                {
                    sendTeamspeakQuery(TeamspeakQuery.buildClientMoveQuery(client.TsClient.tsId.Value, mStagingChannel.tsId.Value));
                    if (!performResponseHandling(Queries.CheckSwapStaging)) return;
                    client.TsClient.medChannelId = mStagingChannel.tsId;
                    debugWrite(dbgSwapping, "[Swapping] - Staging Mode - Client ({0}) from Ch.{1} to Ch.{2}.", client.TsClient.tsName, channelId, client.TsClient.medChannelId);
                    if (mTSSyncedUsers.Contains(client.GmClient.Name) && !mBetweenRounds) // PURE
                    {
                        debugWrite(dbgTSSyncPromote, "[TSSync Promote] - Player (" + client.GmClient.Name + ") is being sent to staging removing from list: " + string.Join(",", mTSSyncedUsers.ToArray()));
                        mTSSyncedUsers.Remove(client.GmClient.Name); // PURE
                    }
                    // Check if channels need to be deleted if the option is set.
                    if (chnRemoveOnEmpty)
                        removeChannels();
                }
            }
            // Move To Team Channel If:
            //   Squad Based swapping is off, or
            //   The number of players is less than the squad swapping threshold, or
            //   The player is not in a squad, or
            //   The number of players in the squad is less than the squad swapping minimum, or
            //   The player is marked as Sync to Team
            else if (!synSquadBasedSwapping || getPlayersOnBothServersOnTeam(client.GmClient.TeamId).Count < synSquadBasedThreshold || client.GmClient.SquadId == 0 || getPlayersOnBothServersOnSquad(client.GmClient.TeamId, client.GmClient.SquadId).Count < synSquadSizeMinimum || client.IsSyncToTeam)
            {
                // Locate / Create the team channel.
                if (!mTeamChannels.ContainsKey(client.GmClient.TeamId))
                {
                    findOrCreateTeamChannel(client.GmClient.TeamId);
                    if (!mTeamChannels.ContainsKey(client.GmClient.TeamId)) return;
                }

                // Move the client to the Team channel.
                if (client.TsClient.medChannelId != mTeamChannels[client.GmClient.TeamId].tsId)
                {
                    sendTeamspeakQuery(TeamspeakQuery.buildClientMoveQuery(client.TsClient.tsId.Value, mTeamChannels[client.GmClient.TeamId].tsId.Value));
                    if (mTsResponse.Id == "768")
                    {
                        mTeamChannels.Remove(client.GmClient.TeamId);
                        mSquadChannels.Remove(client.GmClient.TeamId);
                    }
                    if (!performResponseHandling(Queries.CheckSwapTeam)) return;
                    client.TsClient.medChannelId = mTeamChannels[client.GmClient.TeamId].tsId.Value;
                    debugWrite(dbgSwapping, "[Swapping] - Team Mode - Client ({0}) from Ch.{1} to Ch.{2}.", client.TsClient.tsName, channelId, client.TsClient.medChannelId);

                    // PURE TSSync Promotion
                    showSeedingMessage(client);
                    // Check if channels need to be deleted if the option is set.
                    if (chnRemoveOnEmpty)
                        removeChannels();
                }
            }
            // Move To Squad Channel If:
            //   Well, all other scenarios are out, so it must be this.
            else
            {
                // Locate / Create the team channel.
                if (!mTeamChannels.ContainsKey(client.GmClient.TeamId))
                {
                    findOrCreateTeamChannel(client.GmClient.TeamId);
                    if (!mTeamChannels.ContainsKey(client.GmClient.TeamId)) return;
                }

                // Locate / Create the squad channel.
                if (!mSquadChannels[client.GmClient.TeamId].ContainsKey(client.GmClient.SquadId))
                {
                    findOrCreateSquadChannel(client.GmClient.TeamId, client.GmClient.SquadId);
                    if (!mSquadChannels[client.GmClient.TeamId].ContainsKey(client.GmClient.SquadId)) return;
                }

                // Move the client to the Squad channel
                if (client.TsClient.medChannelId != mSquadChannels[client.GmClient.TeamId][client.GmClient.SquadId].tsId)
                {
                    sendTeamspeakQuery(TeamspeakQuery.buildClientMoveQuery(client.TsClient.tsId.Value, mSquadChannels[client.GmClient.TeamId][client.GmClient.SquadId].tsId.Value));
                    if (mTsResponse.Id == "768")
                    {
                        mSquadChannels[client.GmClient.TeamId].Remove(client.GmClient.SquadId);
                    }
                    if (!performResponseHandling(Queries.CheckSwapSquad)) return;
                    client.TsClient.medChannelId = mSquadChannels[client.GmClient.TeamId][client.GmClient.SquadId].tsId.Value;
                    debugWrite(dbgSwapping, "[Swapping] - Squad Mode - Client ({0}) from Ch.{1} to Ch.{2}.", client.TsClient.tsName, channelId, client.TsClient.medChannelId);

                    // PURE TSSync Promotion
                    showSeedingMessage(client);

                    // Check if channels need to be deleted if the option is set.
                    if (chnRemoveOnEmpty)
                        removeChannels();
                }
            }
        }