|
|
|
@ -27,6 +27,11 @@ namespace JXSoft {
@@ -27,6 +27,11 @@ namespace JXSoft {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public enum ServerState |
|
|
|
|
{ |
|
|
|
|
Close = 0, |
|
|
|
|
Open = 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class HttpServerUtility:IUtility |
|
|
|
|
{ |
|
|
|
@ -40,6 +45,7 @@ namespace JXSoft {
@@ -40,6 +45,7 @@ namespace JXSoft {
|
|
|
|
|
|
|
|
|
|
public Thread reciveT; |
|
|
|
|
|
|
|
|
|
#region OpenServer |
|
|
|
|
public bool startServer(string[] prefixes) { |
|
|
|
|
if (httpServer == null || !httpServer.IsListening) { |
|
|
|
|
if (!HttpListener.IsSupported) |
|
|
|
@ -68,25 +74,27 @@ namespace JXSoft {
@@ -68,25 +74,27 @@ namespace JXSoft {
|
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void startServer(string prefix) { |
|
|
|
|
string[] prefixes = {prefix}; |
|
|
|
|
startServer(prefixes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void startServer() |
|
|
|
|
{ |
|
|
|
|
string[] prefixes = { address }; |
|
|
|
|
startServer(prefixes); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region CloseServer |
|
|
|
|
public void closeServer() { |
|
|
|
|
if (httpServer.IsListening) { |
|
|
|
|
reciveT.Abort(); |
|
|
|
|
httpServer.Close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region MessageReceive |
|
|
|
|
public void RecciveMsg() |
|
|
|
|
{ |
|
|
|
|
string msg = ""; |
|
|
|
@ -120,7 +128,7 @@ namespace JXSoft {
@@ -120,7 +128,7 @@ namespace JXSoft {
|
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 返回消息 |
|
|
|
|
#region 返回应答 |
|
|
|
|
HttpListenerResponse response = context.Response; |
|
|
|
|
// Construct a response. |
|
|
|
|
byte[] buffer = Encoding.UTF8.GetBytes("<HTML><BODY> " + "success" + "</BODY></HTML>"); |
|
|
|
@ -144,7 +152,7 @@ namespace JXSoft {
@@ -144,7 +152,7 @@ namespace JXSoft {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 线程接收到消息后 |
|
|
|
|
/// Update调用,主线程信息提取 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns>接收到的消息</returns> |
|
|
|
|
public string getReceivedValue() |
|
|
|
@ -159,5 +167,6 @@ namespace JXSoft {
@@ -159,5 +167,6 @@ namespace JXSoft {
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
} |