コード例 #1
0
    public void SwapParty()
    {
        if (inactiveParties.Count == 0)
        {
            return;
        }

        inactiveParties.Add(currentParty);
        currentParty.isActive = false;
        currentParty          = inactiveParties[0] as LocalParty;
        currentParty.isActive = true;
        inactiveParties.RemoveAt(0);
    }
コード例 #2
0
ファイル: PartyManager.cs プロジェクト: TheWolfA2/Lighthouse
    public void SwapParty()
    {
        if (inactiveParties.Count == 0)
        {
            return;
        }

        inactiveParties.Add(currentParty);
        currentParty.isActive = false;
        currentParty = inactiveParties[0] as LocalParty;
        currentParty.isActive = true;
        inactiveParties.RemoveAt(0);
    }
コード例 #3
0
ファイル: UserAgent.cs プロジェクト: niklsspb/C-Sharp-Sip-Lib
        /// <summary>
        /// Creates a SIP request.
        /// </summary>
        /// <param name="method">The SIP method (invite etc.)</param>
        /// <param name="content">The SIP body contents.</param>
        /// <param name="contentType">The type of the SIP body.</param>
        /// <returns>Message.</returns>
        public virtual Message CreateRequest(string method, string content = "", string contentType = "")
        {
            Server = false;
            if (RemoteParty == null)
            {
                Debug.Assert(false, String.Format("No remoteParty for UAC\n"));
            }
            if (LocalParty == null)
            {
                LocalParty = new Address("\"Anonymous\" <sip:[email protected]>");
            }
            //TODO: Use Remote Party instead of Remote Target?
            SIPURI uri;

            if (RemoteTarget != null)
            {
                uri = new SIPURI(RemoteTarget.ToString());
            }
            else
            {
                uri = new SIPURI(RemoteParty.ToString());
            }

            if (method == "REGISTER")
            {
                //TODO: Is this right ?
                //uri.User = "";
            }
            if ((method != "ACK") && (method != "CANCEL"))
            {
                LocalSeq = ++LocalSeq;
            }
            //TODO: Use Remote Party instead of Remote Target?
            Header to;

            if (RemoteTarget != null)
            {
                to = new Header(RemoteTarget.ToString(), "To");
            }
            else
            {
                to = new Header(RemoteParty.ToString(), "To");
            }

            Header from = new Header(LocalParty.ToString(), "From");

            from.Attributes["tag"] = LocalTag;
            Header cSeq        = new Header(LocalSeq + " " + method, "CSeq");
            Header callId      = new Header(CallID, "Call-ID");
            Header maxForwards = new Header(MaxForwards.ToString(), "Max-Forwards");
            Header via         = Stack.CreateVia();
            Dictionary <string, object> branchParams = new Dictionary <string, object>
            {
                { "To", to.Value },
                { "From", @from.Value },
                { "CallId", callId.Value },
                { "CSeq", cSeq.Number }
            };

            via.Attributes["branch"] = Transaction.CreateBranch(branchParams, false);
            if (LocalTarget == null)
            {
                LocalTarget      = Stack.Uri.Dup();
                LocalTarget.User = LocalParty.Uri.User;
            }
            Header contact = new Header(LocalTarget.ToString(), "Contact");

            Header[]      headerList = { to, from, cSeq, callId, maxForwards, via, contact };
            List <Header> headers    = headerList.ToList();

            // Check this TODO
            //
            if (RouteSet.Count != 0)
            {
                headers.AddRange(RouteSet);
            }

            //app adds other headers such as Supported, Require and Proxy-Require
            if (!string.IsNullOrEmpty(contentType))
            {
                headers.Add(new Header(contentType, "Content-Type"));
            }
            Dictionary <string, List <Header> > headerDict = new Dictionary <string, List <Header> >();

            foreach (Header h in headers)
            {
                if (headerDict.ContainsKey(h.Name))
                {
                    headerDict[h.Name].Add(h);
                }
                else
                {
                    List <Header> temp = new List <Header> {
                        h
                    };
                    headerDict.Add(h.Name, temp);
                }
            }
            Request = Message.CreateRequest(method, uri, headerDict, content);
            return(Request);
        }
コード例 #4
0
        static int Main()
        {
            /*
             * Завдання:
             *  Створіть застосунок для демонстрації в коді наступних можливостей:
             *  1.	Роботу з масивами(одновимірним (+), двовимірним прямокутним (+) та двовимірним невирівняним () ). Студенти з парними номерами y варіанті
             *  підраховують суму елементів масивів, з непарними- добуток. Розмір масиву підраховується програмно. ()
             *  2.	За допомогою оператора foreach знайдіть в масиві елемент із заданим значенням(значення вводиться з клавіатури). (+)
             *  3.	Продемонструйте роботу основних методів класу Object ()
             *  4.	Продемонструйте використання модифікаторів доступу в межах однієї збірки. (+)
             *  5.	*Додаткове завдання: використання модифікатору private protected (+)
             */
            int prodOneDim = 1, prodMatrixRectangle = 1, prodMatrixJagged = 1;                // jagged array is an array whose elements are arrays

            Console.WriteLine("Type of products in all arrays is {0}", prodOneDim.GetType()); // Object.GetType()
            object oneO   = null;
            object twoO   = null;
            object threeO = new LocalParty();

            Console.WriteLine(LocalParty.ReferenceEquals(oneO, twoO));
            twoO = threeO;
            Console.WriteLine(LocalParty.ReferenceEquals(twoO, threeO));
            Console.WriteLine(LocalParty.ReferenceEquals(oneO, threeO));

            LocalParty objSMPL = new LocalParty();

            Console.WriteLine(objSMPL.ToString());


            //////////////////////////////////////////////////////////////////////

            /*
             * Console.Write("Enter the size of the 1-D array : ");
             * string sizeOneDTMP =  Console.ReadLine();
             * int sizeOneD = int.Parse(sizeOneDTMP);
             *
             * Console.Write("Enter the value you want to find in the 1-D array : ");
             * string valueSearchTMP = Console.ReadLine();
             * int valueSearch = int.Parse(valueSearchTMP);
             *
             *
             * Console.WriteLine("");
             * int[] arrOneDim = new int[sizeOneD]; // 1-D array
             * Random someRandOneD = new Random();
             * for(int i = 0; i < sizeOneD; i++)
             * {
             *  arrOneDim[i] = someRandOneD.Next(-20, 21);
             *  Console.Write($"{arrOneDim[i]} ");
             *  if(i % 4 == 0)
             *  {
             *      Console.WriteLine("");
             *  }
             *  prodOneDim = arrOneDim[i] * prodOneDim;
             * }
             * Console.WriteLine("");
             * Console.WriteLine($"\nProduct of all elements in the array is {prodOneDim}");
             *
             *
             * foreach(int element in arrOneDim) // foreach for 1-D array
             * {
             *  if(element == valueSearch)
             *  {
             *      Console.WriteLine($"\nCoinsidence!!! Your value {valueSearch} matches the value {element} in this array");
             *      break;
             *  }
             *  else
             *  {
             *      Console.WriteLine("\nWell, maybe next time");
             *      break;
             *  }
             * }
             */

            //////////////////////////////////////////////////////////////////////

            /*
             * Console.Write("\nEnter the lines of the 2-D (rechtangle) matrix : "); // 2-D matrix (rechtangle)
             * string sizeMatrixTMPOne = Console.ReadLine();
             *
             * Console.Write("Enter the columns of the 2-D (rechtangle) matrix : ");
             * string sizeMatrixTMPTwo = Console.ReadLine();
             *
             * int sizeMatrixLine = int.Parse(sizeMatrixTMPOne);
             * int sizeMatrixColumn = int.Parse(sizeMatrixTMPTwo);
             * int[,] arrMatrixRechtangle = new int[sizeMatrixLine, sizeMatrixColumn];
             * Random someRandMatrixOne = new Random();
             *
             *
             * for (int i = 0; i < sizeMatrixLine; i++)
             * {
             *  for(int j = 0; j < sizeMatrixColumn; j++)
             *  {
             *      arrMatrixRechtangle[i,j] = someRandMatrixOne.Next(-20, 21);
             *      Console.Write(String.Format("{0,3}", arrMatrixRechtangle[i, j]));
             *      prodMatrixRectangle = arrMatrixRechtangle[i, j] * prodMatrixRectangle;
             *  }
             *  Console.WriteLine();
             * }
             *
             * Console.WriteLine("");
             * Console.WriteLine($"\nProduct of all elements in the (rechtangle) matrix is {prodMatrixRectangle}");
             */

            //////////////////////////////////////////////////////////////////////

            /*
             * Console.Write("\nEnter the amount of arrays in the jagged array : "); // jagged array MUST_FINISH_LATER
             * string sizeJaggedTMP = Console.ReadLine();
             *
             * Console.Write("Enter the camount of elements in each array : ");
             * string sizeArrInJaggedTMP = Console.ReadLine();
             *
             * int sizeJagged = int.Parse(sizeJaggedTMP);
             * int sizeArrInJagged = int.Parse(sizeArrInJaggedTMP);
             * int[][] arrJagged = new int[sizeJagged][];
             * Random someRandMatrixTwo = new Random();
             */

            /*
             * for(int i = 0; i < arrJagged.Length; i++)
             * {
             *  for(int j = 0; j < arrJagged[i].Length; j++)
             *  {
             *      arrJagged[i][j] = someRandMatrixTwo.Next(-20, 21);
             *      //Console.Write("{0}{1}", arrJagged[i][j], j == (arrJagged[i].Length - 1) ? "" : " ");
             *  }
             * }
             */

            int[][] jaggedArr = new int[3][];
            jaggedArr[0] = new int[5] {
                1, 2, 3, 4, 5
            };
            jaggedArr[1] = new int[4] {
                3, 5, 7, 9
            };
            jaggedArr[2] = new int[3] {
                11, 13, 15
            };
            int minLength = jaggedArr[0].Length;


            for (int i = 0; i < jaggedArr.Length; i++)
            {
                Console.Write("Element ({0}): ", i);
                for (int j = 0; j < jaggedArr[i].Length; j++)
                {
                    Console.Write("{0}{1}", jaggedArr[i][j], j == (jaggedArr[i].Length - 1) ? "" : " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();

            for (int i = 0; i < 3; i++)
            {
                if (jaggedArr[i].Length < minLength)
                {
                    minLength = jaggedArr[i].Length;
                }
            }
            Console.WriteLine($"Minimal length is {minLength}");
            Console.WriteLine();

            for (int i = 0; i < jaggedArr.Length; i++)
            {
                Console.Write("Element ({0}): ", i);
                for (int j = 0; j < minLength; j++)
                {
                    Console.Write("{0}{1}", jaggedArr[i][j], j == (jaggedArr[i].Length - 1) ? "" : " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            // add min and max value methods

            /*
             * int i = 0, j = 0;
             * int minValue = jaggedArr[i][j];
             * int maxValaue = jaggedArr[i][j];
             *
             *
             * for (i = 0; i < jaggedArr.Length; i++)
             * {
             *
             *  Console.Write("Element({0}): ", i);
             *  for (j = 0; j < minLength; j++)
             *  {
             *      if(jaggedArr[i][j] < minValue)
             *      {
             *          minValue = jaggedArr[i][j];
             *      }
             *      Console.Write("Min value = {0}", minValue);
             *
             *  }
             *
             *  Console.WriteLine();
             * }
             * Console.WriteLine();
             */


            //////////////////////////////////////////////////////////////////////

            Console.ReadKey();
            return(0);
        }