Exemplo n.º 1
0
        static void Main(string[] args)
        {
            /*
             * Use miniSipServer to create the test server
             */

            string sipDomain   = "10.0.0.52";
            string sipLogin    = "******";
            string sipPassword = "******";
            string localIp     = "10.0.0.55";

            clientSIP = new SipClient(sipDomain, sipLogin, sipPassword);

            logger           = new Logger();
            logger.WriteLog += new WriteLogEventHandler(OnWriteLog);
            clientSIP.Logger = logger;

            clientSIP.ReceiveRequest  += new ReceiveRequestEventHandler(OnReceiveRequest);
            clientSIP.ReceiveResponse += new ReceiveResponseEventHandler(OnReceiveResponse);

            System.Net.IPAddress localAddress = System.Net.IPAddress.Parse(localIp);
            clientSIP.LocalIPEndPoint = new System.Net.IPEndPoint(localAddress, 5060);

            clientSIP.Connect();

            Register register = new Register();

            register.Uri  = string.Format("sip:{0}", sipDomain);
            register.From = new ContactInfo(sipLogin, string.Format("sip:{0}@{1}", sipLogin, sipDomain));
            register.To   = new ContactInfo(sipLogin, string.Format("sip:{0}@{1}", sipLogin, sipDomain));
            register.Header[StandardHeader.Contact] = string.Format("sip:{0}@", sipLogin) + clientSIP.LocalIPEndPoint.ToString();
            register.Expires = 1200;
            clientSIP.SendRequest(register);

            Console.Write("Press any key to continue...");
            Console.ReadLine();

            clientSIP.Unregister(register.Uri, register.From);
        }
Exemplo n.º 2
0
        public void Connect(String userName, String password, String serverIP, UInt16 port)
        {
            if (userName == null)
            {
                throw new NullReferenceException("username is null");
            }
            if (password == null)
            {
                throw new NullReferenceException("password is null");
            }
            if (serverIP == null)
            {
                throw new NullReferenceException("server ip is null");
            }


            client = new SipClient(serverIP, userName, password);
            client.LocalIPEndPoint = new IPEndPoint((Dns.GetHostAddresses(Dns.GetHostName()))[0], port);

            client.Connect();
            client.Register("sip:" + serverIP, "sip:" + userName + "@192.168.1.120", "sip:" + userName + "@" + client.LocalIPEndPoint.ToString());
        }
Exemplo n.º 3
0
        public void onClickCall(object sender, EventArgs e)
        {
            client = new SipClient("coolheatcrm.duckdns.org", "800", "0uts1de");

            //create logger
            logger           = new Logger();
            logger.WriteLog += new WriteLogEventHandler(OnWriteLog);
            client.Logger    = logger;

            client.ReceiveRequest  += new ReceiveRequestEventHandler(OnReceiveRequest);
            client.ReceiveResponse += new ReceiveResponseEventHandler(OnReceiveResponse);

            //IPHostEntry localhost = Dns.Resolve("mycomputer");
            //client.LocalIPEndPoint = new IPEndPoint(localhost.AddressList[0],5060);

            System.Net.IPAddress localAddress = Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault();
            client.LocalIPEndPoint = new System.Net.IPEndPoint(localAddress, 5060);
            client.Connect();
            client.Register("sip:coolheatcrm.duckdns.org", "sip:[email protected]", "sip:800@" + client.LocalIPEndPoint.ToString());

            SessionDescription session = new SessionDescription();

            session.Version = 0;

            Owner owner = new Owner();

            owner.Username  = "******";
            owner.SessionID = 16264;
            owner.Version   = 18299;
            owner.Address   = "" + Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault();

            session.Owner = owner;
            session.Name  = "SIP Call";

            Connection connection = new Connection();

            connection.Address = "" + Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault();

            session.Connection = connection;

            Time time = new Time(0, 0);

            session.Time.Add(time);

            Media media1 = new Media();

            media1.Type = "audio";
            media1.Port = 25282;
            media1.TransportProtocol = "RTP/AVP";
            media1.MediaFormats.Add("0");
            media1.MediaFormats.Add("101");

            media1.Attributes.Add("rtpmap", "0 pcmu/8000");
            media1.Attributes.Add("rtpmap", "101 telephone-event/8000");
            media1.Attributes.Add("fmtp", "101 0-11");

            session.Media.Add(media1);

            RequestResponse inviteRequestResponse = client.Invite("sip:[email protected]", "sip:" + PhoneNumber.Text + "@coolheatcrm.duckdns.org", "sip:800@" + client.LocalIPEndPoint.ToString(), session);

            client.Ack(inviteRequestResponse);

            client.Disconnect();
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     SipClient sipClient = new SipClient();
 }