本文整理汇总了C#中HttpServer.HttpServer.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServer.Add方法的具体用法?C# HttpServer.Add怎么用?C# HttpServer.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpServer.HttpServer
的用法示例。
在下文中一共展示了HttpServer.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
client = new WebClient();
client.Encoding = Encoding.UTF8;
var info = new OBBInfo();
info.ip = IPAddress.Loopback.ToString();
info.notifyPort = Settings.Default.notifyPort;
info.servicePort = Settings.Default.servicePort;
info.serviceRoot = Settings.Default.serviceRoot;
if (String.IsNullOrWhiteSpace(info.serviceRoot))
info.serviceRoot = Environment.CurrentDirectory;
OBBContext.Current.Info = info;
OBBContext.Current.Mode = Settings.Default.mode;
server = new HttpServer.HttpServer();
var fileModule = new FileModule("/", OBBContext.Current.Info.serviceRoot);
var myModule = new MyModule();
fileModule.AddDefaultMimeTypes();
server.Add(myModule);
server.Add(fileModule);
server.Start(IPAddress.Any, OBBContext.Current.Info.servicePort);
if (OBBContext.Current.IsMaster)
{
OBBContext.Current.MasterInfo = OBBContext.Current.Info;
notifyIcon1.Icon = Resources.master;
var port = IPAddress.HostToNetworkOrder(OBBContext.Current.Info.servicePort);
byte[] portData = BitConverter.GetBytes(port);
notify = new UdpNotify(OBBContext.Current.Info.notifyPort, portData);
}
else
{
OBBContext.Current.LoadGameConfig();
notifyIcon1.Icon = Resources.slave;
notify = new UdpNotify(OBBContext.Current.Info.notifyPort);
notify.OnData += Notify_OnData;
}
this.Text = OBBContext.Current.Mode.ToString();
notifyIcon1.Text = OBBContext.Current.Mode.ToString();
refreshTimer.Start();
button1.Enabled = OBBContext.Current.IsMaster;
}
示例2: ObjectForScripting
public ObjectForScripting()
{
httpServer = new HttpServer.HttpServer();
ajaxObjectForScripting = new AjaxObjectForScripting(this);
httpServer.Add(ajaxObjectForScripting);
httpServer.Start(IPAddress.Any, 50505);
httpServer.BackLog = 5;
}
示例3: StartTutorial
public void StartTutorial()
{
_server = new HttpServer.HttpServer();
// Let's use Digest authentication which is superior to basic auth since it
// never sends password in clear text.
DigestAuthentication auth = new DigestAuthentication(OnAuthenticate, OnAuthenticationRequired);
_server.AuthenticationModules.Add(auth);
// simple example of an regexp redirect rule. Go to http://localhost:8081/profile/arne to get redirected.
_server.Add(new RegexRedirectRule("/profile/(?<first>[a-zA-Z0-9]+)", "/user/view/${first}"));
// Let's reuse our module from previous tutorial to handle pages.
_server.Add(new Tutorial3.MyModule());
// and start the server.
_server.Start(IPAddress.Any, 8081);
Console.WriteLine("Goto http://localhost:8081/membersonly to get authenticated.");
Console.WriteLine("Password is 'morsOlle', and userName is 'arne'");
}
示例4: GetCore
internal HttpServer.HttpServer GetCore()
{
if(core == null)
{
// create my dispatcher module
var testModule = new DispatcherModule(GetClassList());
// create session handling
var customComponents = new ComponentProvider();
var sessionStore = new MemorySessionStore();
sessionStore.ExpireTime = 5;
customComponents.AddInstance<IHttpSessionStore>(sessionStore);
core = new HttpServer.HttpServer(customComponents);
core.Add(new HttpModuleWrapper(testModule));
}
return core;
}
示例5: Initialize
public void Initialize()
{
if (_server == null)
{
_port = getFreePort();
_server = new HttpServer(new MyLogWriter());
_server.Add(new MyModule(this));
_server.Start(IPAddress.Loopback, _port);
Trace.WriteLine(
string.Format(
@"[Web server] Started local web server for URL '{0}'.",
baseUrl));
}
}
示例6: StartListening
public void StartListening(IGablarskiServerContext context)
{
var sstore = new MemorySessionStore { ExpireTime = 15 };
server = new HttpServer.HttpServer (sstore);
ConnectionManager cmanager = new ConnectionManager (sstore);
cmanager.ConnectionProvider = this;
cmanager.Server = server;
server.Add (new QueryModule (cmanager));
WebServerConfiguration config = (WebServerConfiguration) ConfigurationManager.GetSection ("webserver");
if (config != null && config.Theme != null)
{
server.Add (new FileResourceModule (config.Theme.Path));
server.Add (new LoginModule (cmanager));
server.Add (new ChannelModule (cmanager));
server.Add (new UserModule (cmanager));
}
server.Start (IPAddress.Any, this.Port);
}
示例7: start_server
private static void start_server()
{
try
{
if (Settings.EnableFileStats)
{
FileSystemStats.Init();
}
HttpServer.HttpServer server = new HttpServer.HttpServer();
server.ServerName = "ChanArchiver " + Version;
server.AuthenticationModules.Add(
new BasicAuthentication(new AuthenticationHandler(authenticate),
new AuthenticationRequiredHandler(check_authenticate)));
// Let the OOP abuse begin
// Page handlers
server.Add(new OverviewPageHandler());
server.Add(new FileQueuePageHandler());
server.Add(new WatchJobsPageHandler());
server.Add(new MonitoredBoardsPageHandler());
server.Add(new ThreadFiltersPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.LogPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.FileInfoPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.ResourcesHandler());
server.Add(new ChanArchiver.HttpServerHandlers.FileHandler());
server.Add(new ChanArchiver.HttpServerHandlers.BannedFilesPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.SettingsPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.ThreadJobInfoPageHandler());
server.Add(new ChanArchiver.HttpServerHandlers.FileBrowserPageHandler());
server.Add(new ThreadServerModule());
// Threads actions
server.Add(new StopAllManuallyAddedThreadsHandler());
server.Add(new ThreadNotesHandler());
server.Add(new DownloadAsZipHandler());
// Settings actions
server.Add(new ThumbnailOnlySettingsController());
// JSON Api
server.Add(new GetThreadsStatisticsJsonApiHandler());
server.Add(new GetDailyNetworkStatisticsJsonApiHandler());
server.Add(new GetMonthlyNetworkStatisticsJsonApiHandler());
server.Add(new GetFileInfoJsonApiHandler());
server.ExceptionThrown += server_ExceptionThrown;
Console.WriteLine("Starting HTTP server...");
server.Start(IPAddress.Any, port);
Console.WriteLine("Website is accessible at (http://*:{0})", port);
}
catch (Exception ex)
{
Console.Beep();
Console.WriteLine("Could not start HTTP server: {0}.", ex.Message);
}
}
示例8: Run
public void Run(int port)
{
var httpServer = new HttpServer.HttpServer {LogWriter = new ConsoleLogWriter()};
httpServer.Add(this);
httpServer.Start(IPAddress.Any, port);
}