//call back void IOPCDataCallback.OnDataChange(int dwTransid, int hGroup, int hrMasterquality, int hrMastererror, int dwCount, IntPtr phClientItems, IntPtr pvValues, IntPtr pwQualities, IntPtr pftTimeStamps, IntPtr ppErrors) { if ((dwCount != 0) && (hGroup == 1)) { int count = (int)dwCount; int runh = (int)phClientItems; int runv = (int)pvValues; int rune = (int)ppErrors; int error; int handle; for (int i = 0; i < count; i++) { error = Marshal.ReadInt32((IntPtr)rune); rune += 4; handle = Marshal.ReadInt32((IntPtr)runh); runh += 4; if (error >= 0) { object variant = Marshal.GetObjectForNativeVariant((IntPtr)runv); CallBackEvent e = new CallBackEvent(handle, variant); //this event will be proccessed by ..... main.CallBackEventListener //CallBack(this, e); } runv += 16; } } }
/// <summary> /// 得到客户端缓存(同步) /// </summary> public void GetCahceSyn(string userid, CallBackEvent callback) { try { TcpCli client = new TcpCli(ShareData.LocalIp, ShareData.LocalPort); MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetCache; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = _coder.GetEncodingBytes(userid); if (SystemConfig.GetCacheWaitSleep) {//socket缓冲区8192问题没有解决时使用延时加载形式去加载缓存数据 msg = client.SendAndBack(msg); callback(msg); } else { client.AsyncSendWithReceiverData(msg, callback); } } catch (Exception ex) { ex.ToString().ErrorLogger(); ShareData.Log.Info(ex); callback(null); } //return ClientCache.SetCache(msgb.Data); }
public bool unregisterHttpCallback(CallBackEvent ev, string tag, out string msg) { tag = tag.ToLower(); msg = ""; if (ev < CallBackEvent.num_types && ev > 0) { msg = "not a valid event"; return(false); } if (!httpCallbacks.ContainsKey(ev)) { msg = "no event registered"; return(false); } int i = httpCallbacks[ev].Count; while (--i > -1) { if (httpCallbacks[ev][i].tag == tag) { httpCallbacks[ev].RemoveAt(i); } } return(true); }
/// <summary> /// 添加委托 /// </summary> /// <param UIName="type"></param> /// <param UIName="handler"></param> public static void AddListener(CallBackType type, CallBackEvent handler) { if (!DicMessages.ContainsKey(type)) { DicMessages.Add(type, null); } DicMessages[type] += handler; }
public bool registerHttpCallback(CallBackEvent ev, string tag, string url, out string msg) { msg = ""; //Console.WriteLine("url : {0}", url); //Console.WriteLine("tag : {0}", tag); //Console.WriteLine("ev : {0}", ev); if (url.Length < 10) { msg = "short url"; return(false); } //Console.WriteLine("reghttp 0"); if (url.Substring(url.Length - 1) != "/") { url += "/"; } //Console.WriteLine("reghttp 1"); Uri uriResult; bool res = Uri.TryCreate(url, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp; //Console.WriteLine("reghttp 2"); if (!res) { msg = "invalid url"; return(false); } if (ev < CallBackEvent.num_types && ev > 0) { msg = "not a valid event"; return(false); } if (tag.Length < 3) { msg = "invalid tag"; return(false); } tag = tag.ToLower(); //Console.WriteLine("reghttp 3"); if (!httpCallbacks.ContainsKey(ev)) { httpCallbacks.Add(ev, new List <CallBackURL>()); } //Console.WriteLine("reghttp 4"); foreach (CallBackURL cb in httpCallbacks[ev]) { if (cb.tag == tag) { cb.url = url; return(true); } } httpCallbacks[ev].Add(new CallBackURL(tag, url)); return(true); }
/// <summary> /// 停止播放声音并停止图标闪动 /// </summary> public void Stop() { try { if (CallBackEvent != null) { CallBackEvent.Invoke(0); } player.Stop(); } catch (Exception ex) { } }
/// <summary> /// 播放提示音并闪动任务栏图标 /// </summary> public void Play() { try { if (CallBackEvent != null) { CallBackEvent.Invoke(1); } player.PlayLooping(); } catch (Exception ex) { } }
private void CreateNewExerciseClick(object param) { if (ValidateUserInput()) { ExerciseDescriptor exercise = new ExerciseDescriptor() { Description = Description, Name = Name }; var ex = RequestCreator.SetExerciseDescriptor(exercise); CallBackEvent?.Invoke(this, ex); PopupNavigation.Instance.PopAsync(); } }
public void httpCallback(CallBackEvent ev, string[] path, string data) { if (ev >= CallBackEvent.num_types || ev <= 0) { return; } //CallbackEvents = { "im", "chat" }; if (httpCallbacks.ContainsKey(ev)) { foreach (CallBackURL callback in httpCallbacks[ev]) { httpClient.PostAsync(callback.url + session + "/" + ev.ToString() + "/" + string.Join("/", path), new StringContent(data, Encoding.UTF8, "application/json")); } } }
public static async void KillRedis(string pathToRedisServer) { Process prs = Process.GetProcesses().Where(_ => _.ProcessName.Equals("redis-server")).FirstOrDefault(); if (prs != null) { prs.Kill(); await CheckRedis("Redis was killed"); } else { CallBackEvent?.Invoke(new GlobalEventArgs { Message = "The process \"redis-server\" was null.\n", clearDisplay = true });; await CheckRedis("Redis wasn't running in the first place"); } }
/// <summary> /// 调用委托 并删除引用 /// </summary> /// <param UIName="type"></param> /// <param UIName="args"></param> public static void CallListener(CallBackType type, params object[] args) { CallBackEvent del; //委托 if (DicMessages.TryGetValue(type, out del)) { if (del != null) { Delegate[] delete = del.GetInvocationList(); if (delete.Length > 0) { CallBackEvent callBack = delete[0] as CallBackEvent; if (callBack != null) { callBack(args); // ReSharper disable once DelegateSubtraction DicMessages[type] -= callBack; } } } } }
private async static Task CheckRedis(string message) { Task <bool> isRedisConnectedTask = isRedisConnected(); System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 100; timer.Tick += (object sender, EventArgs e) => { CallBackEvent?.Invoke(new GlobalEventArgs { Message = ".", clearDisplay = false }); }; timer.Start(); bool is_RedisConnected = await isRedisConnectedTask; timer.Stop(); if (!is_RedisConnected) { CallBackEvent?.Invoke(new GlobalEventArgs { Message = message, clearDisplay = true }); } }
private void CreateFocusPointClick(object param) { if (!string.IsNullOrEmpty(FocusPoint.Name)) { if (ValidateUserInput()) { if (isEdit) { RequestCreator.EditFocusPoint(FocusPoint); } else { FocusPoint = RequestCreator.CreateFocusPointDescriptor(FocusPoint); } CallBackEvent?.Invoke(this, FocusPoint); PopupNavigation.Instance.PopAsync(); } } else { Application.Current.MainPage.DisplayAlert("Alert", "Please enter a name", "Ok"); } }
public void httpCallback(CallBackEvent ev, string path, object data) { httpCallback(ev, new string[] { path }, new JavaScriptSerializer().Serialize(data)); }
// Initialize the Core :D public static void InitCore(CallBackLog l, CallBackEvent e) { // Can't run this more than once if (inited) { return; } // We need to be able to Log stuff if (l == null) { return; } if (e == null) { return; } Log = l; Event = e; Log(LogType.System, "BoogieBot.dll Initializing..."); // Initialize everything try { if (!File.Exists(Environment.CurrentDirectory + "/" + BoogieCore.BoogieBotConfigFileName)) { throw new FileNotFoundException("Configuration file not found.", BoogieCore.BoogieBotConfigFileName); } configFile = new IniReader(Environment.CurrentDirectory + "/boogiebot.ini"); // NOTE: Set any OS specific variables so things can be done differently later, ie. Windows or Linux, etc. OperatingSystem os = Environment.OSVersion; switch (os.Platform) { case PlatformID.Win32Windows: Log(LogType.System, "> Operating System: Windows"); break; case PlatformID.Win32NT: Log(LogType.System, "> Operating System: Windows NT"); break; case PlatformID.Unix: Log(LogType.System, "> Operating System: Unix"); break; } Log(LogType.System, "> OS Version: {0}.{1} (Build: {2}) ({3})", os.Version.Major, os.Version.Minor, os.Version.Build, os.ServicePack); // Find WoW's Folder wowPath = BoogieCore.getWowPath(); Log(LogType.System, "> WowPath: {0}", wowPath); // Find WoW's Version wowVersion = BoogieCore.getWoWVersion(); Log(LogType.System, "> WoW Version: World of Warcraft {0}.{1}.{2}.{3} ({4}) Found! Emulating this version.", wowVersion.major, wowVersion.minor, wowVersion.update, wowVersion.build, BoogieCore.WowTypeString); world = new World(); player = new Player(); //areaTable = new AreaTable(); //mapTable = new MapTable(); } catch (Exception ex) { // Bot Start up Failed. Log why, and rethrow the exception. Log(LogType.System, ex.Message); Log(LogType.System, ex.StackTrace); throw new Exception("BoogieBot.dll Init Failure.", ex); } inited = true; Log(LogType.System, "BoogieBot.dll Initialized."); }
// Initialize the Core :D public static void InitCore(CallBackLog l, CallBackEvent e) { // Can't run this more than once if (inited) return; // We need to be able to Log stuff if (l == null) return; if (e == null) return; Log = l; Event = e; Log(LogType.System, "BoogieBot.dll Initializing..."); // Initialize everything try { if (!File.Exists(Environment.CurrentDirectory + "/" + BoogieCore.BoogieBotConfigFileName)) throw new FileNotFoundException("Configuration file not found.", BoogieCore.BoogieBotConfigFileName); configFile = new IniReader(Environment.CurrentDirectory + "/boogiebot.ini"); // NOTE: Set any OS specific variables so things can be done differently later, ie. Windows or Linux, etc. OperatingSystem os = Environment.OSVersion; switch(os.Platform) { case PlatformID.Win32Windows: Log(LogType.System, "> Operating System: Windows"); break; case PlatformID.Win32NT: Log(LogType.System, "> Operating System: Windows NT"); break; case PlatformID.Unix: Log(LogType.System, "> Operating System: Unix"); break; } Log(LogType.System, "> OS Version: {0}.{1} (Build: {2}) ({3})", os.Version.Major, os.Version.Minor, os.Version.Build, os.ServicePack); // Find WoW's Folder wowPath = BoogieCore.getWowPath(); Log(LogType.System, "> WowPath: {0}", wowPath); // Find WoW's Version wowVersion = BoogieCore.getWoWVersion(); Log(LogType.System, "> WoW Version: World of Warcraft {0}.{1}.{2}.{3} ({4}) Found! Emulating this version.", wowVersion.major, wowVersion.minor, wowVersion.update, wowVersion.build, BoogieCore.WowTypeString); world = new World(); player = new Player(); //areaTable = new AreaTable(); //mapTable = new MapTable(); } catch (Exception ex) { // Bot Start up Failed. Log why, and rethrow the exception. Log(LogType.System, ex.Message); Log(LogType.System, ex.StackTrace); throw new Exception("BoogieBot.dll Init Failure.", ex); } inited = true; Log(LogType.System, "BoogieBot.dll Initialized."); }
public void InitCore(CallBackEvent e) { // Can't run this more than once if (inited) return; // We need to be able to Log stuff //if (l == null) return; if (e == null) return; //Log = l; Event = e; Log.WriteLine(netLogic.Shared.LogType.Debug, "netLogic.dll Initializing..."); // Initialize everything try { if (!File.Exists(Environment.CurrentDirectory + "/" + BoogieBotConfigFileName)) throw new FileNotFoundException("Configuration file not found.", BoogieBotConfigFileName); configFile = new IniReader(Environment.CurrentDirectory + "/netLogic.ini"); // NOTE: Set any OS specific variables so things can be done differently later, ie. Windows or Linux, etc. OperatingSystem os = Environment.OSVersion; switch (os.Platform) { case PlatformID.Win32Windows: Log.WriteLine(netLogic.Shared.LogType.Debug, "> Operating System: Windows"); break; case PlatformID.Win32NT: Log.WriteLine(netLogic.Shared.LogType.Debug, "> Operating System: Windows NT"); break; case PlatformID.Unix: Log.WriteLine(netLogic.Shared.LogType.Debug, "> Operating System: Unix"); break; } Log.WriteLine(netLogic.Shared.LogType.Debug, "> OS Version: {0}.{1} (Build: {2}) ({3})", os.Version.Major, os.Version.Minor, os.Version.Build, os.ServicePack); // Find WoW's Folder wowPath = getWowPath(); Log.WriteLine(netLogic.Shared.LogType.Debug, "> WowPath: {0}", wowPath); // Find WoW's Version wowVersion = getWoWVersion(); Log.WriteLine(netLogic.Shared.LogType.Debug, "> WoW Version: World of Warcraft {0}.{1}.{2}.{3} ({4}) Found! Emulating this version.", wowVersion.major, wowVersion.minor, wowVersion.update, wowVersion.build, netInstance.WowTypeString); //objectMgr = new ObjectMgr(); GameObject _objects = new GameObject("objMgr"); _objects.AddComponent<ObjMgr>(); objMgr = _objects.GetComponent<ObjMgr>(); DontDestroyOnLoad(objMgr); //movementMgr = new MovementMgr(netLogicCore.ObjectMgr); //combatMgr = new CombatMgr(ObjectMgr,MovementMgr); //terrainMgr = new TerrainMgr(); // UpdateFieldsLoader.LoadUpdateFields(wowVersion.build); //areaTable = new AreaTable(); //mapTable = new MapTable(); } catch (Exception ex) { // Bot Start up Failed. Log why, and rethrow the exception. Log.WriteLine(netLogic.Shared.LogType.Debug, ex.Message); Log.WriteLine(netLogic.Shared.LogType.Debug, ex.StackTrace); throw new Exception("BoogieBot.dll Init Failure.", ex); } inited = true; Log.WriteLine(netLogic.Shared.LogType.Debug, "BoogieBot.dll Initialized."); }
private void OnCallBackEvent(SubClassingWindowEventArgs e) { CallBackEvent?.Invoke(this, e); }
private void ListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e) { CallBackEvent?.Invoke(this, e.SelectedItem as Trainer); PopupNavigation.Instance.PopAsync(); }
public void DisplayResult(double a, double b, double result) { Console.WriteLine("{0} * {1} = {2}", a, b, result); CallBackAction?.Invoke("回调"); CallBackEvent?.Invoke("事件"); }
public bool unregisterHttpCallback(CallBackEvent ev, string tag, out string msg) { tag = tag.ToLower(); msg = ""; if (ev < CallBackEvent.num_types && ev > 0) { msg = "not a valid event"; return false; } if (!httpCallbacks.ContainsKey(ev)) { msg = "no event registered"; return false; } int i = httpCallbacks[ev].Count; while(--i > -1) { if (httpCallbacks[ev][i].tag == tag) httpCallbacks[ev].RemoveAt(i); } return true; }
public bool registerHttpCallback(CallBackEvent ev,string tag,string url, out string msg) { msg = ""; //Console.WriteLine("url : {0}", url); //Console.WriteLine("tag : {0}", tag); //Console.WriteLine("ev : {0}", ev); if (url.Length < 10) { msg = "short url"; return false; } //Console.WriteLine("reghttp 0"); if (url.Substring(url.Length - 1) != "/") url += "/"; //Console.WriteLine("reghttp 1"); Uri uriResult; bool res = Uri.TryCreate(url, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp; //Console.WriteLine("reghttp 2"); if(!res) { msg = "invalid url"; return false; } if (ev < CallBackEvent.num_types && ev > 0) { msg = "not a valid event"; return false; } if (tag.Length < 3) { msg = "invalid tag"; return false; } tag = tag.ToLower(); //Console.WriteLine("reghttp 3"); if (!httpCallbacks.ContainsKey(ev)){ httpCallbacks.Add(ev, new List<CallBackURL>()); } //Console.WriteLine("reghttp 4"); foreach (CallBackURL cb in httpCallbacks[ev]) { if (cb.tag == tag) { cb.url = url; return true; } } httpCallbacks[ev].Add(new CallBackURL(tag, url)); return true; }
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { CallBackEvent?.Invoke(this, e.SelectedItem as ExerciseDescriptor); PopupNavigation.Instance.PopAsync(); }
public static void Init(CallBackEvent e) { Event = e; }
public void httpCallback(CallBackEvent ev,string[] path,string data) { if (ev >= CallBackEvent.num_types || ev <= 0) return; //CallbackEvents = { "im", "chat" }; if (httpCallbacks.ContainsKey(ev)) { foreach(CallBackURL callback in httpCallbacks[ev]) { httpClient.PostAsync(callback.url + session + "/" + ev.ToString() + "/" + string.Join("/",path), new StringContent(data, Encoding.UTF8, "application/json")); } } }
private void ListView_ItemSelectedPracticeTeam(object sender, SelectedItemChangedEventArgs e) { CallBackEvent?.Invoke(this, e.SelectedItem as PracticeTeam); PopupNavigation.Instance.PopAsync(); }