示例#1
0
        public static void Main()
        {
//			NetTcpBinding binding;
//			CustomBinding binding;
            BasicHttpBinding          binding;
            CustomPeerResolverService cprs;
//			ServiceEndpoint se;
            ServiceHost sh;

            try {
                cprs = new MyCustomPeerResolverService();
                sh   = new ServiceHost(cprs);
//				binding = new NetTcpBinding ();
//				binding = new CustomBinding ();
//				binding.Elements.Add (new TextMessageEncodingBindingElement ());
//				binding.Elements.Add (new TcpTransportBindingElement ());
                binding = new BasicHttpBinding();
//				binding.Security.Mode = SecurityMode.None;
                sh.AddServiceEndpoint(typeof(IPeerResolverContract),
                                      binding,
                                      new Uri("http://localhost:8080/ChatServer"));
                cprs.ControlShape = true;
                cprs.Open();
                sh.Open();

                Console.WriteLine("Server started successfully.");
                Console.ReadLine();

                cprs.Close();
                sh.Close();
            } catch (Exception e) {
                Console.WriteLine("[!] {0}", e.Message);
            }
        }
示例#2
0
		public static void Main ()
		{
//			NetTcpBinding binding;
//			CustomBinding binding;
			BasicHttpBinding binding;
			CustomPeerResolverService cprs;
//			ServiceEndpoint se;
			ServiceHost sh;

			try {
				cprs = new MyCustomPeerResolverService ();
				sh = new ServiceHost (cprs);
//				binding = new NetTcpBinding ();
//				binding = new CustomBinding ();
//				binding.Elements.Add (new TextMessageEncodingBindingElement ());
//				binding.Elements.Add (new TcpTransportBindingElement ());
				binding = new BasicHttpBinding ();
//				binding.Security.Mode = SecurityMode.None;
				sh.AddServiceEndpoint (typeof (IPeerResolverContract), 
				                               binding, 
				                               new Uri ("http://localhost:8080/ChatServer"));
				cprs.ControlShape = true;
				cprs.Open ();
				sh.Open ();
				
				Console.WriteLine ("Server started successfully.");
				Console.ReadLine ();
				
				cprs.Close ();
				sh.Close ();
			} catch (Exception e) {
				Console.WriteLine ("[!] {0}", e.Message);
			}
		}