예제 #1
0
 protected override void OnStop()
 {
     if (serviceHost != null)
     {
         serviceHost.Close();
         serviceHost = null;
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            #region MD5
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] fromData = Encoding.Unicode.GetBytes(Dns.GetHostName());
            byte[] targetData = md5.ComputeHash(md5.ComputeHash(fromData));
            string byte2String = null;
            for (int i = 3; i < 6; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 0; i < 3; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 9; i < 11; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 12; i < 15; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 6; i < 9; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            targetData = md5.ComputeHash(Encoding.Unicode.GetBytes(byte2String));
            byte2String += "-";
            for (int i = 0; i < 3; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 5; i < 7; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            byte2String += "-";
            for (int i = 9; i < 11; i++)
            {
                byte2String += targetData[i].ToString("x");
            }
            #endregion
            SDCPublish.Server.Host host = new SDCPublish.Server.Host();
            host.Open();
            Console.ReadLine();
            Connection con = new Connection();
            var service = con.FindService();
            foreach (var ser in service)
            {
                var client = con.InvokeService(ser);

                string ip = Dns.GetHostAddresses(ser.Uri.Host)[0].ToString();
                string user = (ser.Uri.Host + ip).ToLower();

                if (client.Connect(Dns.GetHostName(), byte2String))
                {
                    var node = client.GetDirectoryInfo(false);
                    client.SendMessage("TEST Information", "TestTitle");
                }
            }
            Console.ReadLine();

            ////OpenReceive();
            //while (true)
            //{
            //    Console.ReadLine();
            //    MessageCenter.Instance.NotifyMessage(new Message(MessageType.Notify, "Test", "Centent"));
            //}
        }
예제 #3
0
 protected override void OnStart(string[] args)
 {
     serviceHost = new Host();
     serviceHost.Open();
 }