private IStructuralEquatable GetComparisonValuesFromMessage(CallbackMessage message) { IStructuralEquatable result = null; switch (message) { case BrowseCallbackMessage msg: result = (OperationCallbackType.Browse, msg.Payload.Flags.HasFlag(ServiceFlags.Add) ? BrowseEventType.Added : BrowseEventType.Removed, msg.Payload.InstanceName, msg.Payload.ServiceType, msg.Payload.Domain, msg.Payload.InterfaceIndex); break; case RegisterCallbackMessage msg: result = (OperationCallbackType.Register, msg.Payload.Flags.HasFlag(ServiceFlags.Add) ? RegistrationEventType.Added : RegistrationEventType.Removed, msg.Payload.InstanceName, msg.Payload.ServiceType, msg.Payload.Domain, msg.Payload.InterfaceIndex); break; case ResolveCallbackMessage msg: result = (OperationCallbackType.Resolve, msg.Payload.FullName, msg.Payload.HostName, msg.Payload.Port, msg.Payload.TxtRecord, msg.Payload.InterfaceIndex); break; case LookupCallbackMessage msg: result = (OperationCallbackType.Lookup, msg.Payload.Flags.HasFlag(ServiceFlags.Add) ? LookupEventType.Added : LookupEventType.Removed, msg.Payload.HostName, new IPAddress(msg.Payload.RecordData), msg.Payload.TimeToLive, msg.Payload.InterfaceIndex); break; } return(result); }
internal async Task PerformOperationExecuteTestAsSubordinateWithCallback(OperationBase operation, CallbackMessage cbMessage, bool cancelAndCheckStateOnExit = true) { _manualResetEvent.Reset(); _callbackMessageUponRequest = cbMessage; HookOperationEvent(operation); var connOp = await PerformOperationExecuteTestAsPrimary(new ConnectionOperation(), false); await connOp.AddAndExecuteSubordinate(operation); operation.State.Should().Be(OperationState.Executing); if (await WaitForCallback()) { GetComparisonValuesFromMessage(cbMessage).Equals(CallbackValues).Should().Be(true); } else { throw new Exception("Timeout waiting for callback message"); } ThrowIfConnectorClosed(); if (cancelAndCheckStateOnExit) { await operation.CancelAsync(); operation.State.Should().Be(OperationState.Canceled); await connOp.CancelAsync(); connOp.State.Should().Be(OperationState.Canceled); } }
/// <summary> /// 响应消息 /// </summary> /// <param name="proxy"></param> /// <param name="method"></param> /// <param name="parameters"></param> /// <returns></returns> public object Invoke(object proxy, System.Reflection.MethodInfo method, object[] parameters) { if (client.CommunicationState == CommunicationStates.Connected) { //定义回调的消息 var message = new CallbackMessage { ServiceName = callType.FullName, MethodName = method.ToString(), Parameters = parameters }; //加入队列 lock (queue.SyncRoot) { queue.Enqueue(new CallbackInfo { Client = client, Message = message }); } //返回null return(null); } else { throw new SocketException((int)SocketError.ConnectionAborted); } }
internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message is LookupCallbackMessage lcm) { // *** Comment from Bonjour/dnssd_clientstubb/handle_addrinfo_response() function *** // We only generate client callbacks for A and AAAA results (including NXDOMAIN results for // those types, if the client has requested those with the kDNSServiceFlagsReturnIntermediates). // Other result types, specifically CNAME referrals, are not communicated to the client, because // the DNSServiceGetAddrInfoReply interface doesn't have any meaningful way to communiate CNAME referrals. IPAddress ipa = null; if (lcm.Payload.RecordLength != 0 && (lcm.Payload.RecordType == ResourceRecordType.A || lcm.Payload.RecordType == ResourceRecordType.AAAA)) { var i = 0; ipa = new IPAddress(ServiceMessage.GetSubArray(lcm.Payload.RecordData, ref i, lcm.Payload.RecordLength)); } var eventType = LookupEventType.None; if (lcm.Payload.Error != ServiceError.NoError) { eventType = lcm.Payload.Error == ServiceError.Timeout ? LookupEventType.Timeout : lcm.Payload.Error == ServiceError.NoSuchRecord ? LookupEventType.NoSuchRecord : LookupEventType.Error; } else { eventType = lcm.Payload.Flags.HasFlag(ServiceFlags.Add) ? LookupEventType.Added : LookupEventType.Removed; } LookupEvent?.Invoke(Token, new LookupEventArgs(eventType, lcm.Payload.HostName, ipa, lcm.Payload.TimeToLive, lcm.Payload.InterfaceIndex, moreComing)); } }
public void RunCallbacks(bool server) { if (this.RunningCallbacks) { return; } this.RunningCallbacks = true; CallbackMessage message = new CallbackMessage(); int call = 0; while (Steam.GetCallback(this.Pipe, ref message, ref call)) { foreach (ICallback callback in this.Callbacks.Where <ICallback>((Func <ICallback, bool>)(candidate => { if (candidate.Id == message.m_iCallback) { return(candidate.Server == server); } return(false); }))) { callback.Run(message.m_pubParam); } Steam.FreeLastCallback(this.Pipe); } this.RunningCallbacks = false; }
internal void GetException(CallbackMessage msg) { if (msg.StopProcess) { throw new StopProcessException(); } }
internal void callMessage(string MethodName, object[] parameters, Type type) { if (messageListener == null) { return; } Type allmsgreciver = typeof(IOtherMessageReceiver); Type messagelistener = typeof(IMessageListener); object[] processAllInterfacesParamters = new object[] { parameters[0], parameters[1] }; foreach (CallablePlugin plugin in messageListener) { if (allmsgreciver.IsAssignableFrom(plugin.type)) { // 判断当前循环中的类是不是处理所有消息的接口 if (allmsgreciver.IsAssignableFrom(type)) { // 判断传入的类是不是处理所有消息的接口 try { CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } else { try { CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin("ReceiveAllNormalMessage", processAllInterfacesParamters); GetException(resultobj); } catch (NotImplementedException) { } } continue; } if (allmsgreciver.IsAssignableFrom(type)) { // 如果传入的是处理所有消息的接口则忽略(因为没有共同的方法) continue; } else if (messagelistener.IsAssignableFrom(plugin.type)) { // 如果这个类是处理普通消息的接口则运行这个插件 try { CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } continue; } if (type.IsAssignableFrom(plugin.type)) { // 如果这个类与传入的接口相同则运行这个插件 try { CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } } }
internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message is BrowseCallbackMessage brm) { BrowseEvent?.Invoke(Token, new BrowseEventArgs(brm.Payload.Flags.HasFlag(ServiceFlags.Add) ? BrowseEventType.Added : BrowseEventType.Removed, new ServiceDescriptor(brm.Payload.InstanceName, brm.Payload.ServiceType, brm.Payload.Domain, brm.Payload.InterfaceIndex), moreComing)); } }
public void MessagesCtorTest() { var msgBase = new MessageBase(); var dlgMsg = new DialogMessage("Test"); var callbackMsg = new CallbackMessage(OnCallbackMessage); Assert.Throws <ArgumentNullException>(() => new CallbackMessage(null)); }
public void MessageCallback(DateTime date, Guid chatGuid, string message, Guid selfGuid) { var data = new MessageCallbackData(); data.Date = date; data.ChatGuid = chatGuid; data.Message = message; data.SendedUserGuid = selfGuid; CallbackMessage?.Invoke(data, EventArgs.Empty); }
internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message is RegisterCallbackMessage rcm) { var error = rcm.Payload.Error; var descriptor = new ServiceDescriptor(rcm.Payload.InstanceName, rcm.Payload.ServiceType, rcm.Payload.Domain, rcm.Payload.InterfaceIndex); var type = error == ServiceError.NoError ? rcm.Payload.Flags.HasFlag(ServiceFlags.Add) ? RegistrationEventType.Added : RegistrationEventType.Removed : RegistrationEventType.Error; RegistrationEvent?.Invoke(Token, new RegistrationEventArgs(type, descriptor, error, moreComing)); } }
public void CallbackMessageTest() { _testCallbackCalledSend = false; var messenger = Messenger.CreateInstance(); var callbackMessage = new CallbackMessage(OnCallbackMessage); messenger.Register <CallbackMessage>(null, msg => msg.Execute()); messenger.Send(callbackMessage); Assert.True(_testCallbackCalledSend); }
public void Callback(string res) { int handlerNum = -1; CallbackMessage message = new CallbackMessage(res); handlerNum = message.GetHandlerNum(); CallbackManager.OnResponse handler = CallbackManager.GetHandler(handlerNum); if (null != handler) { handler(message); } }
public Cipher GetCipherData(CipherType cipherType) { string returnString = sessionAndroidClass.CallStatic <string>("nmg_session_getCipherData", (int)cipherType); CallbackMessage message = new CallbackMessage(returnString); int cipherTypeNum = message.GetInt("cipherTypeNum"); string secretKey = message.GetString("secretKey"); string aesInitialVector = message.GetString("aesInitialVector"); Cipher cipher = new Cipher((CipherType)cipherTypeNum, secretKey, aesInitialVector); return(cipher); }
public Cipher GetCipherData(CipherType cipherType) { string returnString = Marshal.PtrToStringAuto(nmg_session_getCipherData((int)cipherType)); CallbackMessage message = new CallbackMessage(returnString); int cipherTypeNum = message.GetInt("cipherTypeNum"); string secretKey = message.GetString("secretKey"); string aesInitialVector = message.GetString("aesInitialVector"); Cipher cipher = new Cipher((CipherType)cipherTypeNum, secretKey, aesInitialVector); return(cipher); }
private void ShowInput(CallbackMessage <InputVM> msg) { WinInput win = new WinInput(); win.Owner = this; win.SetValue(DataContextProperty, msg.Message); var result = win.ShowDialog(); if (result.HasValue && result.Value) { msg.Callback(msg.Message); } }
internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message.Header.OperationCode != OperationCode.RegisterRecordReply) { if (_subordinates.TryGetValue(message.Header.SubordinateID, out var operation)) { operation?.ProcessReply(message, moreComing); } } else // Not handling register record reply yet { throw new NotImplementedException(); } }
internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message is ResolveCallbackMessage rcm) { IEnumerable <DnssdTxtRecord> records = null; if (rcm.Payload.TxtRecord != null) { var trb = new TxtRecordBuilder(); trb.Parse(rcm.Payload.TxtRecord, 0); records = trb.TxtRecords; } ResolveEvent?.Invoke(Token, new ResolveEventArgs(rcm.Payload.FullName, rcm.Payload.HostName, rcm.Payload.Port, rcm.Payload.InterfaceIndex, records, moreComing)); } }
internal void callMessage(string MethodName, object[] parameters) { object[] processAllInterfacesParamters = { parameters[0], parameters[1] }; if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject callMesasge(non type)"); } if (messageListener == null) { return; } foreach (CallablePlugin plugin in messageListener) { if (typeof(IMessageListener).IsAssignableFrom(plugin.type)) { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject(forEach0g) -> " + MethodName); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } if (typeof(IOtherMessageReceiver).IsAssignableFrom(plugin.type)) { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : ReceiveAllNormalMessage"); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin("ReceiveAllNormalMessage", processAllInterfacesParamters); GetException(resultobj); } catch (NotImplementedException) { } } } }
private static async Task DoWork(IServiceProvider serviceProvider) { var _context = serviceProvider.GetService <DatabaseContext>(); var callbackMessages = await _context.VkCallbackMessages .Where(x => !x.IsProcessed) .Select(x => new CallbackMessage() { IdGroup = x.IdGroup, IdVkCallbackMessage = x.Id, Object = CallbackMessage.FromJson(x.Object), Type = x.Type }).ToArrayAsync(); foreach (var message in callbackMessages) { var function = callbackFunctions.FirstOrDefault(x => x.Item1 == message.Type); if (function == null) { continue; } bool hasError = false; try { await function.Item2.Invoke(serviceProvider, _context, message); } catch (Exception ex) { Console.WriteLine($"VkCallbackWorkerService exception: {ex.Message}{Environment.NewLine}{ex.StackTrace}"); hasError = true; } var callbackMessage = await _context.VkCallbackMessages.FindAsync(message.IdVkCallbackMessage); if (callbackMessage == null) { continue; } callbackMessage.IsProcessed = true; callbackMessage.HasError = hasError; await _context.SaveChangesAsync(); } }
public Client(string id, string ip, int port, ResponceType responceType) { _userHandle = GCHandle.Alloc(_userDataDummy, GCHandleType.Pinned); _userData = _userHandle.AddrOfPinnedObject(); _clientId = CreateClient(id, ip, port, _userData); _сallbackConnectedInstance = onConnect; _callbackDisconnectedInstance = onDisconnect; _callbackMessageInstance = onMessage; _callbackBitmapInstance = onBitmap; _callbackFrameInstance = onFrame; RegisterConnectedHandler(_clientId, _сallbackConnectedInstance); RegisterDisconnectedHandler(_clientId, _callbackDisconnectedInstance); RegisterMessageHandler(_clientId, responceType, _callbackMessageInstance); RegisterBitmapHandler(_clientId, _callbackBitmapInstance); RegisterFrameHandler(_clientId, _callbackFrameInstance); }
internal void callMessage(string MethodName, object[] parameters) { if (messageListener == null) { return; } foreach (CallablePlugin plugin in messageListener) { if (typeof(IMessageListener).IsAssignableFrom(plugin.type)) { try { CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } } }
public void SetCallback(CallbackMessage p) { pCallback = p; clsRegistry reg = new clsRegistry(); uint x; x = reg.GetDWORDValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field\\Streaming\\DropBox", "InitializeDropBoxOnStart"); if (reg.strRegError == null) { if (x == 1) { if (m_runDropBoxThread == null || m_runDropBoxThread.IsAlive == false) { m_runDropBoxThread = new Thread(RunBoxInitialize); m_runDropBoxThread.Start(); } } } }
public void DisposeRegistrationTest() { var messenger = Messenger.CreateInstance(); _testCallbackCalledSend = false; var obj0 = new object(); var callbackMessage = new CallbackMessage(OnCallbackMessage); var registration = messenger.Register <CallbackMessage>(this, ExecuteCallback); messenger.Send(callbackMessage); Assert.True(_testCallbackCalledSend); _testCallbackCalledSend = false; registration.Dispose(); messenger.Send(callbackMessage); Assert.False(_testCallbackCalledSend); }
private void ReportSaveAs(CallbackMessage <ReportVM> msg) { InputVM inputVM = new InputVM { Title = "请输入模板名称" }; WinInput win = new WinInput(); win.Owner = this; win.SetValue(DataContextProperty, inputVM); var result = win.ShowDialog(); if (result.HasValue && result.Value) { var id = Guid.NewGuid().ToString(); _designer.Report.Save($"{Funs.ReportsFolder}/{id}.frx"); reoGrid.Save($"{Funs.ReportsFolder}/{id}.xlsx"); msg.Callback(new ReportVM { Id = id, ReportName = inputVM.Text }); } }
internal void callMessage(string MethodName, object[] parameters, Type type) { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject callMesasge -> " + MethodName); } if (messageListener == null) { return; } Type allmsgreciver = typeof(IOtherMessageReceiver); Type messagelistener = typeof(IMessageListener); object[] processAllInterfacesParamters = { parameters[0], parameters[1] }; foreach (CallablePlugin plugin in messageListener) { if (allmsgreciver.IsAssignableFrom(plugin.type)) { // 判断当前循环中的类是不是处理所有消息的接口 if (allmsgreciver.IsAssignableFrom(type)) { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject(forEach1) -> " + MethodName); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } else { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : ReceiveAllNormalMessage"); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin("ReceiveAllNormalMessage", processAllInterfacesParamters); GetException(resultobj); } catch (NotImplementedException) { } } continue; } if (allmsgreciver.IsAssignableFrom(type)) { continue; } if (messagelistener.IsAssignableFrom(plugin.type)) { // 如果这个类是处理普通消息的接口则运行这个插件 try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject(forEach2) -> " + MethodName); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } continue; } if (type.IsAssignableFrom(plugin.type)) { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : PluginObject(forEach3) -> " + MethodName); } CallbackMessage resultobj = (CallbackMessage)plugin.callPlugin(MethodName, parameters); GetException(resultobj); } catch (NotImplementedException) { } } } }
public CommonWebViewConfiguration() { string defaultValue = null; Log.Debug("[CommonWebView] GetDefaultValue"); #if !UNITY_EDITOR && UNITY_ANDROID AndroidJavaClass commonWebViewClass = new AndroidJavaClass("com.netmarble.unity.NMGCommonWebViewUnity"); defaultValue = commonWebViewClass.CallStatic <string>("nmg_commonWebView_getDefaultValue"); #elif !UNITY_EDITOR && (UNITY_IPHONE || UNITY_IOS) defaultValue = Marshal.PtrToStringAuto(nmg_commonWebView_getDefaultValue()); #endif Log.Debug("[CommonWebView] GetDefaultValue : " + defaultValue); if (!string.IsNullOrEmpty(defaultValue)) { CallbackMessage message = new CallbackMessage(defaultValue); this.useTitleBar = message.GetBool("useTitleBar"); this.useDetailTitleBar = message.GetBool("useDetailTitleBar"); this.strokeColor = message.GetString("strokeColor"); this.useDim = message.GetBool("useDim"); this.useFloatingBackButton = message.GetBool("useFloatingBackButton"); this.useControllerBar = message.GetBool("useControllerBar"); IDictionary controllerBarDic = message.GetDictionary("controllerBarConfiguration"); bool dafaultUseBack = Convert.ToBoolean(controllerBarDic["useBack"].ToString()); bool dafaultUseForward = Convert.ToBoolean(controllerBarDic["useForward"].ToString()); bool dafaultUseRefresh = Convert.ToBoolean(controllerBarDic["useRefresh"].ToString()); bool dafaultUseBrowser = Convert.ToBoolean(controllerBarDic["useBrowser"].ToString()); bool dafaultUseShare = Convert.ToBoolean(controllerBarDic["useShare"].ToString()); this.controllerBarConfiguration = new ControllerBarConfiguration(dafaultUseBack, dafaultUseForward, dafaultUseRefresh, dafaultUseBrowser, dafaultUseShare); this.useRotation = message.GetBool("useRotation"); this.useProgressBar = message.GetBool("useProgressBar"); this.useNotShowToday = message.GetBool("useNotShowToday"); this.useLocalData = message.GetBool("useLocalData"); #if !UNITY_EDITOR && UNITY_ANDROID this.useImmersiveSticky = (ImmersiveMode)message.GetInt("useImmersiveSticky"); #elif !UNITY_EDITOR && (UNITY_IPHONE || UNITY_IOS) this.useImmersiveSticky = ImmersiveMode.None; #endif } else { this.useTitleBar = true; this.useDetailTitleBar = true; this.strokeColor = "#FFCC00"; this.useDim = false; this.useFloatingBackButton = false; this.useControllerBar = false; bool dafaultUseBack = true; bool dafaultUseForward = true; bool dafaultUseRefresh = true; bool dafaultUseBrowser = true; bool dafaultUseShare = true; this.controllerBarConfiguration = new ControllerBarConfiguration(dafaultUseBack, dafaultUseForward, dafaultUseRefresh, dafaultUseBrowser, dafaultUseShare); this.useRotation = true; this.useProgressBar = true; this.useNotShowToday = false; this.useLocalData = false; this.useImmersiveSticky = ImmersiveMode.None; } }
public void SetCallback(CallbackMessage p) { pCallback = p; }
private static async Task <bool> IsPassedCallbackMessage(DatabaseContext _context, CallbackMessage message) { string json = message.ToJSON(); var callbackMessages = await _context.VkCallbackMessages.Where(x => x.Type == message.Type && x.IdGroup == message.IdGroup && x.Object == json && x.IsProcessed).ToArrayAsync(); if (callbackMessages != null && callbackMessages.Any(x => x.Id != message.IdVkCallbackMessage)) { await _context.VkCallbackMessages.Where(x => x.Type == message.Type && x.IdGroup == message.IdGroup && x.Object == json && !x.IsProcessed).ForEachAsync(x => x.IsProcessed = true); await _context.SaveChangesAsync(); return(true); } return(false); }
private static async Task UserUnblock(IServiceProvider serviceProvider, DatabaseContext context, CallbackMessage message) { var innerMessage = message.Object.ToObject <UserUnblock>(); var vkPoolService = serviceProvider.GetService <VkPoolService>(); var subscriber = await VkHelper.CreateSubscriber(context, vkPoolService, message.IdGroup, innerMessage.IdUser); if (subscriber == null) { return; } subscriber.IsBlocked = false; await context.History_GroupActions.AddAsync(new History_GroupActions() { ActionType = (int)Models.Database.Common.GroupActionTypes.Unblocked, IdGroup = message.IdGroup, IdSubscriber = subscriber.Id, Dt = DateTime.UtcNow }); await context.SaveChangesAsync(); }