Example #1
0
    void choosePorts()
    {
        //if toOperator, one port needs to be operator port
        Call   call    = new Call();
        string socketA = getAvailablePort();

        if (socketA == null)           // nothing available
        {
            return;
        }
        sockControl.reserveForCall(socketA);

        string socketB;

        socketB = getAvailablePort();
        if (socketB == null)          // nothing available, clear A.
        {
            sockControl.unreserveForCall(socketA);
            return;
        }
        sockControl.reserveForCall(socketB);

        call.targetPort   = socketA;
        call.incomingPort = socketB;
        call.fromName     = sockControl.getSocket(call.incomingPort).getRandomName();
        call.toName       = sockControl.getSocket(call.targetPort).getRandomName();
        call.operatorConv = loader.getRandomOperatorConversation();
        call.operatorConv.setFormatter(call.toName);


        bool to   = false;
        bool from = false;

        if (badGuyNames.Contains(call.toName))
        {
            to = true;
        }
        if (badGuyNames.Contains(call.fromName))
        {
            from = true;
        }
        call.tappedConv             = loader.getRandomBadConvo(from, to);
        call.tappedConv.toReplace   = call.toName;
        call.tappedConv.fromReplace = call.fromName;



        //Display the input socket as lit up
        //tell andy code to listen for connection
        callsToday++;
        calls.Add(call);
    }