You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
namespace SMWebServer
|
|
{
|
|
public class MsgHandler
|
|
{
|
|
public void HandlerMsg(RequestPacket packet)
|
|
{
|
|
switch (packet.MsgID)
|
|
{
|
|
case (int)SMMsgID.ConsoleCommandRes:
|
|
OnConsoleCommandRes(packet);
|
|
break;
|
|
default:
|
|
TraceLog.Error("MsgHandler.HandlerMsg unknow msgId {0}", packet.MsgID);
|
|
break;
|
|
}
|
|
|
|
}
|
|
private void OnConsoleCommandRes(RequestPacket packet)
|
|
{
|
|
|
|
SMConsoleCommandRes res = (SMConsoleCommandRes)packet.Message;
|
|
|
|
string msg = PassMsg(res);
|
|
OnSendHttpRes(packet.ServerID, msg);
|
|
Console.WriteLine(res.Message);
|
|
}
|
|
private static string PassMsg(SMConsoleCommandRes res)
|
|
{
|
|
switch (res.Command)
|
|
{
|
|
case "list *":
|
|
return TheServers.OnPassHttpRes(res.Message);
|
|
}
|
|
return "";
|
|
|
|
}
|
|
private void OnSendHttpRes(uint Httpid, string msg)
|
|
{
|
|
var info = Program.m_httpService.m_requestList.Find(f => f.Http.id == Httpid);
|
|
|
|
if (info != null)
|
|
{
|
|
info.Http.httpResponse.ContentAsUTF8 = msg;
|
|
info.Http.httpResponse.IsWaitFor = false;
|
|
info.ProcessEnd = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|