using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
using Android.App;
|
using Android.Content;
|
using Android.OS;
|
using Android.Runtime;
|
using Android.Views;
|
using Android.Widget;
|
|
using Java.Net;
|
using Shared.Other;
|
|
namespace com.hdl.on
|
{
|
public class Server : Java.Lang.Thread
|
{
|
private ServerSocket listener = null;
|
private bool running = true;
|
private string documentRoot;
|
private Context context;
|
|
public static int Port=22222;
|
|
public static List<Socket> clientList = new List<Socket>();
|
|
public Server(string documentRoot, Context context):base()
|
{
|
this.documentRoot = documentRoot;
|
this.context = context;
|
listener = new ServerSocket(Port);
|
}
|
|
public override void Run()
|
{
|
while (running)
|
{
|
try
|
{
|
var client = listener.Accept();
|
|
new ServerHandler(documentRoot, context, client).Start();
|
clientList.Add(client);
|
}
|
catch (Exception e)
|
{
|
Android.Util.Log.Error("Webserver", e.Message);
|
}
|
}
|
}
|
|
|
|
public void stopServer()
|
{
|
running = false;
|
try
|
{
|
listener.Close();
|
}
|
catch (Exception e)
|
{
|
Android.Util.Log.Error("Webserver", e.Message);
|
}
|
}
|
|
public static void remove(Socket s)
|
{
|
clientList.Remove(s);
|
}
|
}
|
}
|