private void ExceptionHanlder(ICallInfo info, Exception exception) { Log.Error(logCountGuard, string.Format("Exception during plugin call. Request:OperationCode:{0}, Parameteres:{1}, WebFlags:{2}.Exception Msg:{3}", info.OperationRequest.OperationCode, JsonConvert.SerializeObject(info.OperationRequest.Parameters, serializeSettings), info.OperationRequest.WebFlags, exception.Message), exception); try { this.Plugin.ReportError(Photon.Hive.Plugin.ErrorCodes.UnhandledException, exception); } catch (Exception e) { Log.Error(logCountGuard2, string.Format("Exception ReportError call. Request:OperationCode:{0}, Parameteres:{1}, WebFlags:{2}.Exception Msg:{3}", info.OperationRequest.OperationCode, JsonConvert.SerializeObject(info.OperationRequest.Parameters, serializeSettings), info.OperationRequest.WebFlags, e.Message), e); } finally { CallFailSafe(info, exception.ToString()); } }
private void MethodBody(ICallInfo info, string methodName) { this.PluginHost.LogDebug("Executing method: " + methodName); if (this.callBefore) { this.PluginHost.LogDebug("Creating timer before 'Continue'. method: " + methodName); this.CreateTimer(info, methodName); } if (!this.continueInCallback) { this.PluginHost.LogDebug("calling 'Continue' from method body . method: " + methodName); info.Continue(); } if (this.callAfter) { this.PluginHost.LogDebug("Creating timer after 'Continue'. method: " + methodName); this.CreateTimer(info, methodName); } if (this.fromHttpCallback) { this.PluginHost.LogDebug("Http request. method: " + methodName); this.DoHttpCall(info, (response, state) => { this.PluginHost.LogDebug("Executing http callback for method:" + methodName); this.CreateTimer(info, methodName); }); } }
public async Task StartRecordingOnBridge(string bridgeId, ICallInfo callState) { var recordingId = await _ariClient.StartRecordingOnBridgeAsync( bridgeId, GetFileName(bridgeId, "B", callState)); _recordingsInProgress.Add(bridgeId, recordingId); }
public void IncomingCall(object sender, ICallInfo callInfo) { MessageHandlerEvent(this, $"Запрос входящего соединения на терминале {callInfo.OutgoingNumber} от абонента {callInfo.ClientNumberOfTelephone}"); MessageHandlerEvent(this, $"Принять звонок Y/N"); string answer = null; while (answer != "Y" && answer != "y" && answer != "N" && answer != "n") { answer = Console.ReadLine().ToString(); if (answer == "Y" || answer == "y") { Answer(this, callInfo); } else if (answer == "N" || answer == "n") { Drop(this, callInfo); } else { MessageHandlerEvent(this, "Некорректный ввод"); } } }
public async Task StartRecordingOnLine(string lineId, string direction, ICallInfo callState) { var recordingId = await _ariClient.StartRecordingOnLineAsync( lineId, GetFileName(lineId, direction, callState)); _recordingsInProgress.Add(lineId, recordingId); }
/// <summary>The method was already called in the stack.</summary> public void RecursiveCall(ICallInfo callInfo, ActionSet callerSet) { // Push object array. if (_builder.Controller.Attributes.RecursiveRequiresObjectStack) { actionSet.AddAction(_objectStore.ModifyVariable(Operation.AppendToArray, (Element)callerSet.CurrentObject)); } // Push new parameters. _builder.ParameterHandler.Push(callerSet, callInfo.Parameters.Select(p => p.Value).ToArray()); // Add to the continue skip array. var skipLength = new NumberElement(); actionSet.AddAction(_continueArray.ModifyVariable( Operation.AppendToArray, skipLength )); // Restart the method. SkipStartMarker resetSkip = new SkipStartMarker(actionSet); resetSkip.SetEndMarker(_endOfMethod); actionSet.AddAction(resetSkip); SkipEndMarker continueAtMarker = new SkipEndMarker(); actionSet.AddAction(continueAtMarker); skipLength.Value = _continueAt.NumberOfActionsToMarker(continueAtMarker); }
private static void CallFailSafe(ICallInfo info, string errorMessage) { if (!info.IsProcessed) { info.Fail(errorMessage); } }
public IWorkshopTree Call(ICallInfo call) { // Get the subroutine. _subroutine = Controller.GetSubroutine(); if (_subroutine) { ParameterHandler = _subroutine.ParameterHandler; SetParameters(call); // Store the object the subroutine is executing with. if (Controller.Attributes.IsInstance) { // Normal if (!Controller.Attributes.IsRecursive) { ActionSet.AddAction(_subroutine.ObjectStack.SetVariable((Element)ActionSet.CurrentObject)); } // Recursive: Stack else { ActionSet.AddAction(_subroutine.ObjectStack.ModifyVariable(Operation.AppendToArray, Element.CreateArray(ActionSet.CurrentObject))); } } call.ExecuteSubroutine(ActionSet, _subroutine.Subroutine); // If a return handler was provided, bridge the return value. if (call.ProvidedReturnHandler != null && _subroutine.ReturnHandler != null) { call.ProvidedReturnHandler.ReturnValue(_subroutine.ReturnHandler.GetReturnedValue()); } return(_subroutine.ReturnHandler?.GetReturnedValue()); } else { // Inline // Recursive stack. if (Controller.Attributes.IsRecursive) { var lastCall = GetExistingStack(); // Function is not yet on the stack. if (lastCall == null) { return(BuildInline(call)); } else // Recursive call. { lastCall.RecursiveCall(call, ActionSet); return(ActionSet.ReturnHandler.GetReturnedValue()); } } else { return(BuildInline(call)); } } }
private void OutgoingCallHandler(object sender, ICallInfo callInfo) { if (On) { BusyPort(); PortOutgoingCallEvent?.Invoke(this, callInfo); } ; }
private Hashtable GetCreateGameRequestGameProperties(ICallInfo info) { object resultObject; info.OperationRequest.Parameters.TryGetValue(248, out resultObject); var result = resultObject as Hashtable; return(result ?? new Hashtable()); }
public static HttpResponseImpl CreateHttpResponse(HttpRequest request, ICallInfo info, HttpRequestQueueResultCode result, AsyncHttpRequest asyncHttpRequest) { var statusCode = -1; string statusDescription; byte[] responseData = null; NameValueCollection headers = null; try { switch (result) { case HttpRequestQueueResultCode.Success: statusCode = (int)asyncHttpRequest.WebResponse.StatusCode; statusDescription = asyncHttpRequest.WebResponse.StatusDescription; responseData = asyncHttpRequest.Response; headers = asyncHttpRequest.WebResponse.Headers; break; case HttpRequestQueueResultCode.Error: if (asyncHttpRequest.WebResponse != null) { statusCode = (int)asyncHttpRequest.WebResponse.StatusCode; statusDescription = asyncHttpRequest.WebResponse.StatusDescription; headers = asyncHttpRequest.WebResponse.Headers; } else { statusDescription = asyncHttpRequest.Exception.Message; } break; default: statusCode = -1; statusDescription = String.Empty; break; } } catch (Exception ex) { // we should never get her statusDescription = ex.Message; log.Warn("Exception during http response creation", ex); } var webStatus = asyncHttpRequest == null ? -1 : (int)asyncHttpRequest.WebStatus; if (asyncHttpRequest != null) { asyncHttpRequest.Dispose(); } return(new HttpResponseImpl(request, info, responseData, result, statusCode, statusDescription, webStatus, headers)); }
/// <summary> /// Check if any of the processing method was called for the passed ICallInfo argument. /// </summary> /// <param name="callInfo"></param> protected virtual void StrictModeCheck(ICallInfo callInfo) { if (this.UseStrictMode && callInfo.IsNew) { var infoTypeName = callInfo.GetType().ToString(); ((IGamePlugin)this).ReportError(Photon.Hive.Plugin.ErrorCodes.MissingCallProcessing, null, infoTypeName); callInfo.Fail(string.Format("none of {0}'s method were called", infoTypeName)); } }
public void ParamHook(Hook hook, object[] parameters, ICallInfo callInfo) { if (hook.Cond?.Invoke(callInfo) == false) { return; } _tempCheckResults.Clear(); hook.ParamDelegate?.Invoke(parameters[hook.ParamNo]); GatherCallResults(hook); }
public void CallHook(Hook hook, ICallInfo callInfo) { if (hook.Cond?.Invoke(callInfo) == false) { return; } _tempCheckResults.Clear(); hook.CallDelegate?.Invoke(callInfo); GatherCallResults(hook); }
private void StrictModeCheck(ICallInfo callInfo) { string errorMsg; if (!callInfo.StrictModeCheck(out errorMsg)) { var infoTypeName = callInfo.GetType().ToString(); ((IGamePlugin)this).ReportError(Photon.Hive.Plugin.ErrorCodes.MissingCallProcessing, null, infoTypeName); callInfo.Fail(errorMsg); } }
public void Drop(object sender, ICallInfo callInfo) { MessageHandler?.Invoke(sender, $"Соединение абонента {callInfo.ClientNumberOfTelephone} c абонентом {callInfo.OutgoingNumber} сброшено, абонент надоступен"); IPort port = Ports.FirstOrDefault(x => x.Terminal.ClientNumberOfTelephone == callInfo.ClientNumberOfTelephone); if (port != null) { port.RidPort(); } callInfo = null; }
public void IncomingCall(ICallInfo callInfo) { if (On && !Busy) { BusyPort(); PortIncomingCallEvent?.Invoke(this, callInfo); } else { DropIncomingCallEvent?.Invoke(this, callInfo); } }
public static ICallInfo EntityToDTO(ICallInfo info) { return(new Billing.BL.BusinessEntities.CallInfo() { Id = info.Id, Source = EntityToDTO(info.Source), Target = EntityToDTO(info.Target), Started = info.Started, Duration = info.Duration, Cost = info.Cost }); }
public static ICallInfo DTOtoEntity(ICallInfo info) { return(new CallInfo() { Id = info.Id, Source = DTOtoEntity(info.Source) as Terminal, Target = DTOtoEntity(info.Target) as Terminal, Started = info.Started, Duration = info.Duration, Cost = info.Cost }); }
public HttpResponseImpl(HttpRequest request, ICallInfo info, byte[] responseData, HttpRequestQueueResultCode status, int httpCode, string reason, int webStatus, NameValueCollection headers) { this.Request = request; this.responseData = responseData; this.responseText = responseData == null ? null : Encoding.UTF8.GetString(responseData, 0, responseData.Length); this.status = (byte)status; this.httpCode = httpCode; this.reason = reason; this.webStatus = webStatus; this.CallInfo = info; this.Headers = headers; }
void SetParameters(ICallInfo call) { var parameterValues = call.Parameters.Select(p => p.Value).ToArray(); if (!Controller.Attributes.IsRecursive) { ParameterHandler.Set(ActionSet, parameterValues); } else { ParameterHandler.Push(ActionSet, parameterValues); } }
public void CallHandler(object sender, ICallInfo callInfo) { IPort port = GetPortByOutgoingNumber(callInfo.OutgoingNumber); if (port != null) { port.IncomingCall(callInfo); } else { Drop(sender, callInfo); } }
private void CreateTimer(ICallInfo info, string methodName) { Action timerCallback = () => { this.PluginHost.LogDebug("Executing timer callback for method:" + methodName); if (this.continueInCallback) { info.Continue(); } this.BroadcastEvent(123, null); }; this.PluginHost.CreateOneTimeTimer(info, timerCallback, 100); }
public void SetAdditionalInfo(IUser user, ICallInfo callInfo) { if (callInfo.GetCallState() == CallState.Outgoing) { var cost = callInfo.GetUser().GetTarif() * (callInfo.GetDuration().Minutes * 60 + callInfo.GetDuration().Seconds); var money = callInfo.GetUser().GetMoney() - callInfo.GetCost(); new User(user.GetGuid(), User.GetName(), money); new CallInfo(callInfo.GetPhoneNumber(), callInfo.GetTarget(), callInfo.GetStarted(), callInfo.GetDuration(), user, cost); } else { var cost = 0; new CallInfo(callInfo.GetPhoneNumber(), callInfo.GetTarget(), callInfo.GetStarted(), callInfo.GetDuration(), user, cost); } }
public void SetAdditionalInfo(IUser user, ICallInfo callInfo) { callInfo.User = user; if (callInfo.GetCallState() == CallState.Outgoing) { callInfo.Cost = callInfo.User.Tariff.CostPerSecond * (callInfo.GetDuration().Minutes * 60 + callInfo.GetDuration().Seconds); callInfo.User.Money -= callInfo.Cost; var money -= callInfo. } else { var cost = 0; callInfo.Cost = 0; } }
public decimal CalculateCost(ICallInfo info, IEnumerable <ICallInfo> previousItems) { TimeSpan sum = new TimeSpan(); previousItems.Aggregate(sum, (seed, x) => seed + x.Duration); if (sum.TotalMinutes + info.Duration.TotalMinutes <= _freeMinutes) { return(0); } else { return((decimal)(sum.TotalMinutes + info.Duration.TotalMinutes - _freeMinutes) * _costPerMinute); } }
public void DropCall(object sender, ICallInfo callInfo) { try { IPort port1 = PortController_.Ports.FirstOrDefault(x => x.Terminal.ClientNumberOfTelephone == callInfo.ClientNumberOfTelephone); IPort port2 = PortController_.Ports.FirstOrDefault(x => x.Terminal.ClientNumberOfTelephone == callInfo.OutgoingNumber); port1.RidPort(); port2.RidPort(); MessageHandler(this, $"Абонент {callInfo.OutgoingNumber} отклонил вызов от абонента {callInfo.ClientNumberOfTelephone}"); } catch { throw new Exception("Exception on method DropCall"); } }
IWorkshopTree BuildInline(ICallInfo call) { ModifySet(a => a.New(Controller.Attributes.IsRecursive)); // Create parameter handlers ParameterHandler = Controller.CreateParameterHandler(ActionSet, call.Parameters); // Setup inline-recursive handler. RecursiveStack stack = null; if (!_subroutine && Controller.Attributes.IsRecursive) { stack = new RecursiveStack(this, Controller.StackIdentifier()); stack.Init(); ActionSet.Translate.MethodStack.Add(stack); } ModifySet(a => a.PackThis().ContainVariableAssigner()); // Setup the return handler. if (call.ProvidedReturnHandler != null) { ReturnHandler = call.ProvidedReturnHandler; ModifySet(a => a.New(call.ProvidedReturnHandler)); } else { SetupReturnHandler(); } SetParameters(call); // Set the parameters. AddParametersToAssigner(); stack?.StartRecursiveLoop(); // Start the recursion loop. Controller.Build(ActionSet); // Build the function contents. ReturnHandler.ApplyReturnSkips(); // Returns will skip to this point, right before the recursive loop ends. stack?.EndRecursiveLoop(); // End the recursive loop. if (stack != null) { ActionSet.Translate.MethodStack.Remove(stack); // Remove recursion info from the stack. } return(ReturnHandler.GetReturnedValue()); }
public void _CompleteInfo(ICallInfo info, params object[] outputs) { var internalInfo = (IInternalCallInfo)info; internalInfo.Outputs = outputs; if (DoSpy) { foreach (var h in internalInfo.ElemCheckers.Where(ch => ch.HookType == HookType.Output)) { _spyResultManager.ParamHook(h, outputs, info); } foreach (var h in internalInfo.ElemCheckers.Where(ch => ch.HookType == HookType.AfterCall)) { _spyResultManager.CallHook(h, info); } } }
// Calls the lambda subroutine public IWorkshopTree Call(ActionSet actionSet, ICallInfo call, CodeType expectedType) { WorkshopFunctionBuilder.Call(actionSet, call, this); // No return type expected. if (expectedType == null) { return(null); } // Make sure the returnRecycler is reset. _returnRecycler.Reset(); return(expectedType.GetRealType(actionSet.ThisTypeLinker).GetGettableAssigner(new AssigningAttributes("todo:name", true, false)) .GetValue(new GettableAssignerValueInfo(actionSet) { IndexReferenceCreator = _returnRecycler, SetInitialValue = SetInitialValue.DoNotSet }) .GetVariable()); }
private Hashtable GetCreateGameRequestGameProperties(ICallInfo info) { object resultObject; info.OperationRequest.Parameters.TryGetValue(248, out resultObject); var result = resultObject as Hashtable; return result ?? new Hashtable(); }
void IPluginHost.BroadcastErrorInfoEvent(string message, ICallInfo info, Plugin.SendParameters sendParameters) { this.PublishEvent(new ErrorInfoEvent(message), this.Actors, MakeSendParams(sendParameters)); }