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.
 
 
 
 
 
 

107 lines
2.9 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using Google.Protobuf.WellKnownTypes;
using System.Diagnostics;
namespace SMAgent
{
public class MsgHandler
{
public void HandlerMsg(RequestPacket packet)
{
switch (packet.MsgID)
{
case (int)SMMsgID.ClientRegRes:
OnClientRegRes(packet);
break;
case (int)SMMsgID.AgentDoCommandReq:
OnAgentDoCommandReq(packet);
break;
// 文件传送在center和agent之间是双向, 可以center传给agent, 也可以agent传给center
case (int)SMMsgID.TransFileNotify:
OnTransFileNotify(packet);
break;
case (int)SMMsgID.FileContentReq:
OnFileContentReq(packet);
break;
case (int)SMMsgID.FileContentRes:
OnFileContentRes(packet);
break;
// 文件传送结果由recvNode主动通知transNode
case (int)SMMsgID.FileRecvStateReq:
OnFileRecvStateReq(packet);
break;
case (int)SMMsgID.FileRecvStateRes:
OnFileRecvStateRes(packet);
break;
case (int)SMMsgID.CancelTransNotify:
OnCancelTransNotify(packet);
break;
default:
TraceLog.Error("MsgHandler.HandlerMsg unknow msgId {0}", packet.MsgID);
break;
}
}
private void OnClientRegRes(RequestPacket packet)
{
SMClientRegRes regRes = (SMClientRegRes)packet.Message;
SMAgentCheckProcStat.Instance.OnClientRegRes(regRes);
}
private void OnAgentDoCommandReq(RequestPacket packet)
{
SMAgentDoCommandReq req = (SMAgentDoCommandReq)packet.Message;
SMAgentCommand.Instance.OnCommand(req);
}
private void OnTransFileNotify(RequestPacket packet)
{
var notify = (SMTransFileNotify)packet.Message;
AgentFileRecvMng.Instance.OnTransFileNotify(notify);
}
private void OnFileContentReq(RequestPacket packet)
{
var req = (SMFileContentReq)packet.Message;
AgentFileTransMng.Instance.OnFileContentReq(req);
}
private void OnFileContentRes(RequestPacket packet)
{
var res = (SMFileContentRes)packet.Message;
AgentFileRecvMng.Instance.OnFileContentRes(res);
}
private void OnFileRecvStateReq(RequestPacket packet)
{
var req = (SMFileRecvStateReq)packet.Message;
AgentFileTransMng.Instance.OnFileRecvStateReq(req);
}
private void OnFileRecvStateRes(RequestPacket packet)
{
var res = (SMFileRecvStateRes)packet.Message;
AgentFileRecvMng.Instance.OnFileRecvStateRes(res);
}
private void OnCancelTransNotify(RequestPacket packet)
{
var notify = (SMCancelTransNotify)packet.Message;
AgentFileRecvMng.Instance.OnCancelTransNotify(notify);
}
}
}