当前位置: 首页>>代码示例>>C#>>正文


C# Server.Start方法代码示例

本文整理汇总了C#中Server.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Start方法的具体用法?C# Server.Start怎么用?C# Server.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            consoleLogTypes |= LogType.Information;
            consoleLogTypes |= LogType.Warning;
            consoleLogTypes |= LogType.Error;
            consoleLogTypes |= LogType.FatalError;
            consoleLogTypes |= LogType.UserCommand;
            consoleLogTypes |= LogType.UserActivity;
            consoleLogTypes |= LogType.SuspiciousActivity;
            consoleLogTypes |= LogType.ConsoleOutput;
            consoleLogTypes |= LogType.IRCChat;
            consoleLogTypes |= LogType.PrivateChat;
            consoleLogTypes |= LogType.WorldChat;
            consoleLogTypes |= LogType.OpChat;
            consoleLogTypes |= LogType.GlobalChat;

            try
            {
                server = new Server();
                Logger.OnLog += Log;
                server.OnSettingsUpdate += SettingsUpdate;
                server.Start();
                server.ParseInput();
            }
            catch (Exception e)
            {
                Console.WriteLine("Console: " + e.Message);
            }
        }
开发者ID:ZakAmirz,项目名称:MCSharp,代码行数:29,代码来源:Program.cs

示例2: Start

        /// <summary>
        /// Starts the web server.
        /// </summary>
        public void Start()
        {
            new Thread(() =>
            {
                // create the cross process service
                var svcHost = new ServiceHost(_serviceProvider, new Uri("net.pipe://localhost/testhost"));
                svcHost.AddServiceEndpoint(typeof(ITestHostService), new NetNamedPipeBinding(), "");

                // service must be set to single instance mode 
                svcHost.Description.Behaviors.Find<ServiceBehaviorAttribute>()
                    .InstanceContextMode = InstanceContextMode.Single;

                // open and wait for close event
                svcHost.Open();
                _hostCloseEvent.WaitOne();
                svcHost.Close();
            }).Start();

            new Thread(() =>
            {
                // start the web server process
                var server = new Server(_port, "/", _physicalPath);

                // start and wait for cstop event
                server.Start();
                _serverStopEvent.WaitOne();
                server.Stop();
            }).Start();
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:32,代码来源:TestServer.cs

示例3: DescriptionCacheTest

 public void DescriptionCacheTest()
 {
     var factory = new DummyDeserializerFactory ();
     using (var server = new Server (CreateRoot ())) {
         using (var client = new Client (factory.CreateDeserializer)) {
             client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)));
             client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (2, 0)));
             flag = false;
             client.ServiceAdded += (sender, args) => {
                 lock (mutex) {
                     var service = args.Service.GetService ();
                     Assert.IsNotNull (service);
                     if (flag) {
                         Monitor.Pulse (mutex);
                     } else {
                         flag = true;
                     }
                 }
             };
             lock (mutex) {
                 server.Start ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The server announcement timed out.");
                 }
                 Assert.AreEqual (1, factory.InstantiationCount);
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:29,代码来源:ClientTests.cs

示例4: Main

        static void Main(string[] args)
        {
            Server myServer = new Server();

            myServer.Setup();
            myServer.Start();
        }
开发者ID:jamesdesouza,项目名称:WebSocketsDemo,代码行数:7,代码来源:Program.cs

示例5: Window_Loaded

 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Server srv = new Server();
     string msgAvvio = "Creato il server";
     lstMSG.Items.Add(msgAvvio);
     srv.Start();
 }
开发者ID:Tacconi,项目名称:FLIP,代码行数:7,代码来源:MainWindow.xaml.cs

示例6: Main

        public static void Main(string[] args)
        {
            string name = "Foobar Mirror";
            ushort port = 3690;

            if (args.Length > 0)
                name = args[0];
            if (args.Length > 1)
                port = UInt16.Parse (args[1]);

            server = new Server (name);
            server.Port = port;
            server.Start ();

            ServiceLocator locator = new ServiceLocator ();
            locator.Found += OnServiceFound;
            locator.Removed += OnServiceRemoved;
            locator.Start ();

            Console.WriteLine ("Press enter to quit");
            Console.ReadLine ();

            foreach (Client client in clients) {
                client.Logout ();
            }

            locator.Stop ();
            server.Stop ();
        }
开发者ID:mono,项目名称:daap-sharp,代码行数:29,代码来源:Mirror.cs

示例7: TenConcurrentSimpleGet

 public void TenConcurrentSimpleGet()
 {
     var server = new Server(3002);
     server.Start(Application.Run);
     var uri = new Uri("http://localhost:3002/");
     var bag = new ConcurrentBag<string>();
     const int count = 10;
     for (int i = 0; i < count; i++)
     {
         var client = new WebClient();
         client.DownloadStringCompleted += (sender, args) =>
             {
                 bag.Add(args.Result);
                 client.Dispose();
             };
         client.DownloadStringAsync(uri);
     }
     SpinWait.SpinUntil(() => bag.Count == count);
     server.Stop();
     Assert.Equal(count, bag.Count);
     int iteration = 0;
     foreach (var actual in bag)
     {
         Assert.Equal(Index.Html, actual);
     }
 }
开发者ID:bentayloruk,项目名称:Flux,代码行数:26,代码来源:HttpClientGetTest.cs

示例8: Main

 public static void Main(string[] args)
 {
     Server Servidor = new Server("127.0.0.1", 7777);
       Servidor.Start();
       Servidor.Stop();
       System.Console.WriteLine("ya ta!!");
 }
开发者ID:alvarezdaniel,项目名称:inworx-curso-dotnet,代码行数:7,代码来源:ServerUI.cs

示例9: Menu

 public Menu()
 {
     Zoom = 1.5;
     BackgroundColor = Color.Sky;
     var list = new UI.ElementList();
     int port = 11000;
     list.Add(new UI.Button("Start", () => {
         var server = new Server(port);
         var view = new ClientView("127.0.0.1", port);
         server.Start();
         view.OnClose += server.Stop;
         PushState(view);
     }));
     list.Add(new UI.Button("Start splitscreen", () => {
         var server = new Server(port);
         var view = new SplitScreen("127.0.0.1", port);
         server.Start();
         view.OnClose += server.Stop;
         PushState(view);
     }));
     var l2 = new UI.ElementList();
     l2.Horizontal = true;
     var ipInput = new UI.TextInput(200);
     l2.Add(ipInput);
     l2.Add(new UI.Button("Connect", () => {
         PushState(new ClientView(ipInput.Value, port));
     }));
     list.Add(l2);
     list.Anchor = list.Origin = new Vec2(0.5, 0.5);
     Frame.Add(list);
 }
开发者ID:kuviman,项目名称:QGame,代码行数:31,代码来源:QGame.cs

示例10: Main

	static void Main ()
	{
		Server server = new Server ();
		server.Start ();

		Client client = new Client ();

		try {
			client.SendRequest (false, false);
			Assert.Fail ("#A1");
		} catch (WebException ex) {
			Assert.IsNotNull (ex.Response, "#A2");
			Assert.IsTrue (ex.Response is HttpWebResponse, "#A3");

			HttpWebResponse response = (HttpWebResponse) ex.Response;
			Assert.AreEqual (HttpStatusCode.Unauthorized, response.StatusCode, "#A4");
			Assert.IsNull (ex.InnerException, "#A5");
			Assert.IsFalse (server.Callback, "#A6");
		}

		server.Reset ();

		client.SendRequest (true, false);
		Thread.Sleep (200);
		Assert.IsTrue (server.Callback, "#B");

		server.Reset ();

		client.SendRequest (true, true);
		Thread.Sleep (200);
		Assert.IsTrue (server.Callback, "#C");

		server.Stop ();
	}
开发者ID:mono,项目名称:gert,代码行数:34,代码来源:test.cs

示例11: Test_Server_Returns_Correct_Ident_String

        public void Test_Server_Returns_Correct_Ident_String()
        {
            using (Server server = new Server())
            {
                server.Start();

                TcpClient connection = new TcpClient();

                try
                {
                    connection.Connect("localhost", 1400);
                }
                catch (SocketException e)
                {
                    Assert.True(false, "Failed to connect to socket. " + e.Message);
                }

                Assert.True(connection.Connected);

                // read the data from the socket
                byte[] data = new byte[512];

                NetworkStream stream = connection.GetStream();
                stream.ReadTimeout = 200;
                int readResult = stream.Read(data, 0, data.Length);

                Assert.True(readResult > 0, "Failed reading from client");

                // get the version string
                string version = Encoding.UTF8.GetString(data, 0, readResult);
                string expectedVersion = Server.Version;

                Assert.Equal(expectedVersion, version);
            }
        }
开发者ID:browsk,项目名称:XStreamer,代码行数:35,代码来源:ServerTests.cs

示例12: Main

        static void Main(string[] args)
        {
            Debug.Listeners.Add(new ConsoleTraceListener());
            Debug.AutoFlush = true;

            string url = "http://localhost:8081/";
            var server = new Server(url);
            server.Configuration.DisconnectTimeout = TimeSpan.Zero;

            // Map connections
            server.MapConnection<MyConnection>("/echo")
                  .MapConnection<Raw>("/raw")
                  .MapHubs();

            server.Start();

            Console.WriteLine("Server running on {0}", url);

            while (true)
            {
                ConsoleKeyInfo ki = Console.ReadKey(true);
                if (ki.Key == ConsoleKey.X)
                {
                    break;
                }
            }
        }
开发者ID:nairit,项目名称:SignalR,代码行数:27,代码来源:Program.cs

示例13: Program

        private Program()
        {
            Log.Info("Loading settings");
            Config.Load();

            AppDomain.CurrentDomain.UnhandledException += (s, e) => {
                Log.Fatal(e.ExceptionObject.ToString());
            };

            Log.Info("Connecting to database");
            Database.Instance.Connect();

            String region = Database.Instance.GetServerRegion(Config.ServerId);
            if (region == String.Empty)
                Log.Fatal("Server region not found");

            Database.Instance.CleanServerStatus(Config.ServerId);

            String listen = String.Format("ws://{0}:{1}/", Config.Host, Config.Port);
            Server server = new Server(region);
            server.Start(listen);

            Database.Instance.ServerStatus(Config.ServerId, Config.Host + ":" + Config.Port, true);

            AppDomain.CurrentDomain.ProcessExit += (s, e) =>
            {
                Database.Instance.ServerStatus(Config.ServerId, null, false);
            };

            while(true)
                Console.ReadKey();
        }
开发者ID:jjkl,项目名称:AgarioServer,代码行数:32,代码来源:Program.cs

示例14: Form1

        public Form1()
        {
            InitializeComponent();
            listView1.Items.Clear();
            listView1.View = View.Details;
            listView1.Columns.Add("Path");
            listView1.Columns[0].Width = listView1.Width - 4;
            listView1.HeaderStyle = ColumnHeaderStyle.None;

            string dir = "D:\\iTunes Music\\Music";
            List<System.IO.FileInfo> files = new List<FileInfo>();
            List<string> dirs = new List<string>(Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories));
            foreach (var subDir in dirs)
            {
                FileInfo file = new FileInfo(subDir);
                TagLib.File sameFile = TagLib.File.Create(subDir);
                Console.WriteLine(subDir);
                int length = sameFile.Tag.Performers.Length;
                listView1.Items.Add(new ListViewItem("Title: " + sameFile.Tag.Title + "  -  Artist: " + (length > 0 ? sameFile.Tag.Performers[0] : "")));
            }
            Console.WriteLine("\n{0} directories found.", dirs.Count);

            Server server = new Server("http://*:8000/");
            server.AddRequestHandler(new DiffSyncRequestHandler());
            server.Start();
        }
开发者ID:jordanbang,项目名称:MusicDiff-Windows,代码行数:26,代码来源:Form1.cs

示例15: StartServer

 public void StartServer(int port)
 {
     StopServer();
     server = new Server(port);
     server.RegisterLogDelegate(logServer);
     server.Start();
 }
开发者ID:davidhart,项目名称:micro,代码行数:7,代码来源:ServerSession.cs


注:本文中的Server.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。