本文整理汇总了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);
}
}
示例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();
}
示例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);
}
}
}
}
示例4: Main
static void Main(string[] args)
{
Server myServer = new Server();
myServer.Setup();
myServer.Start();
}
示例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();
}
示例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 ();
}
示例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);
}
}
示例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!!");
}
示例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);
}
示例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 ();
}
示例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);
}
}
示例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;
}
}
}
示例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();
}
示例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();
}
示例15: StartServer
public void StartServer(int port)
{
StopServer();
server = new Server(port);
server.RegisterLogDelegate(logServer);
server.Start();
}