Beispiel #1
0
 public Client(OperationContext operationContext)
 {
     var clientProp = operationContext.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
     Address = clientProp.Address;
     SampleWCFClient1 = operationContext.GetCallbackChannel<IShihandaiServiceToShihan>();
     CallbackChannel = SampleWCFClient1 as IChannel;
     State = ClientState.Idling;
 }
 private static void Log(OperationContext context, string s) {
     if (context.RequestContext.RequestMessage.State == MessageState.Closed) {
         Unsubscribe(context);
         Console.WriteLine($"Subscriber {context.SessionId} left without unsubscribing");
     }
     else {
         var proxy = context.GetCallbackChannel<IPubSubServiceCallback>();
         proxy.CallBack(s);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Start the monitor
        /// </summary>
        public async Task <CloudJob> StartAsync(System.ServiceModel.OperationContext context)
        {
            TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitorEntry] Start monitor Entry.");
            this.currentState = Telepathy.Session.Data.JobState.Queued;
            this.context      = context.GetCallbackChannel <ISchedulerNotify>();
            this.cloudJob     = await this.batchClient.JobOperations.GetJobAsync(AzureBatchSessionJobIdConverter.ConvertToAzureBatchJobId(this.sessionid));

            if (this.cloudJob.State == JobState.Disabled)
            {
                ThrowHelper.ThrowSessionFault(SOAFaultCode.Session_ValidateJobFailed_JobCanceled, SR.SessionLauncher_ValidateJobFailed_JobCanceled, this.sessionid.ToString());
            }

            if (this.cloudJob.Metadata != null)
            {
                MetadataItem maxUnitsItem = this.cloudJob.Metadata.FirstOrDefault(item => item.Name == "MaxUnits");
                if (maxUnitsItem != null)
                {
                    if (Int32.TryParse(maxUnitsItem.Value, out int result))
                    {
                        this.maxUnits = result;
                    }
                }
            }

            // monitor batch job state
            this.batchJobMonitor = new AzureBatchJobMonitor(this.sessionid, this.JobMonitor_OnReportJobState);
            try
            {
                Task.Run(() => this.StartMonitorAsync());
            }
            catch (Exception e)
            {
                TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitorEntry] Exception thrown when start Azure Batch Job Monitor: {0}", e);
            }

            return(this.cloudJob);
        }
Beispiel #4
0
 T IOperationContext.GetCallbackChannel <T>()
 {
     return(context.GetCallbackChannel <T>());
 }