Exemplo n.º 1
0
        public void HandleCommandComplete(Broker broker, IDecoder decoder, long sequence)
        {
            long   code    = decoder.ReadUint32();
            string text    = decoder.ReadStr8();
            Object context = this.SequenceManager.Release(sequence);

            if (context.Equals(CONTEXT_STARTUP))
            {
                broker.DecrementOutstanding();
            }
            else
            {
                if ((context.Equals(CONTEXT_SYNC)) & broker.GetSyncInFlight())
                {
                    broker.SetSyncInFlight(false);
                }
                else
                {
                    if (context.Equals(CONTEXT_MULTIGET) && SyncSequenceList.Contains(sequence))
                    {
                        lock (LockObject) {
                            SyncSequenceList.Remove(sequence);
                            if (SyncSequenceList.Count == 0)
                            {
                                Monitor.PulseAll(LockObject);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected long SendMethodRequest(QMFObject obj, Broker aBroker, string name, List <object> args, bool synchronous, int timeToLive)
        {
            SchemaMethod method = obj.Schema.GetMethod(name);

            if (args == null)
            {
                args = new List <object>();
            }

            long seq = 0;

            if (method != null)
            {
                KeyValuePair <SchemaMethod, bool> pair = new KeyValuePair <SchemaMethod, bool>(method, synchronous);
                seq = SequenceManager.Reserve(pair);
                IEncoder enc = aBroker.CreateEncoder('M', seq);
                obj.ObjectID.encode(enc);
                obj.Schema.Key.encode(enc);
                enc.WriteStr8(name);

                if (args.Count < method.InputArgCount)
                {
                    throw new Exception(String.Format("Incorrect number of arguments: expected {0}, got{1}", method.InputArgCount, args.Count));
                }

                int argIndex = 0;
                foreach (SchemaArgument arg in method.Arguments)
                {
                    if (arg.IsInput())
                    {
                        ;
                        this.EncodeValue(enc, arg.Type, args[argIndex]);
                        argIndex += 1;
                    }
                }

                Message msg = aBroker.CreateMessage(enc, obj.RoutingKey(), timeToLive);

                if (synchronous)
                {
                    aBroker.SetSyncInFlight(true);
                }
                aBroker.Send(msg);
            }
            return(seq);
        }
Exemplo n.º 3
0
        public void HandleMethodResponse(Broker broker, IDecoder decoder, long sequence)
        {
            long   code = decoder.ReadUint32();
            string text = decoder.ReadStr16();

            Dictionary <string, object> outArgs = new Dictionary <string, object>();
            object obj = SequenceManager.Release(sequence);

            if (obj == null)
            {
                return;
            }

            KeyValuePair <SchemaMethod, bool> pair = (KeyValuePair <SchemaMethod, bool>)obj;

            if (code == 0)
            {
                foreach (SchemaArgument arg in pair.Key.Arguments)
                {
                    if (arg.IsOutput())
                    {
                        outArgs.Add(arg.Name, this.DecodeValue(decoder, arg.Type));
                    }
                }
            }

            MethodResult result = new MethodResult(code, text, outArgs);

            if (pair.Value)
            {
                this.SyncResult = result;
                broker.SetSyncInFlight(false);
            }

            if (Console != null)
            {
                Console.MethodResponse(broker, sequence, result);
            }
        }
Exemplo n.º 4
0
		public void HandleMethodResponse(Broker broker, IDecoder decoder, long sequence) {	
			long code = decoder.ReadUint32() ;
			string text = decoder.ReadStr16() ;
			
			Dictionary<string, object> outArgs = new Dictionary<string, object>() ;
			object obj = SequenceManager.Release(sequence) ;
			
			if (obj == null) { 
				return ;
			}
			
			KeyValuePair<SchemaMethod, bool> pair = (KeyValuePair<SchemaMethod, bool>) obj  ;			
			if (code == 0) {
				foreach (SchemaArgument arg in pair.Key.Arguments) {
					if (arg.IsOutput()) {
						outArgs.Add(arg.Name, this.DecodeValue(decoder, arg.Type)) ;	
					}
				}
			}
			
			MethodResult result = new MethodResult(code, text, outArgs) ;
			
			if (pair.Value) {
				this.SyncResult = result;
				broker.SetSyncInFlight(false) ;
			}
			
			if (Console != null) {
				Console.MethodResponse(broker, sequence, result) ;
			}	
		}	
Exemplo n.º 5
0
		public void HandleCommandComplete(Broker broker, IDecoder decoder, long sequence) {
		
			long code = decoder.ReadUint32() ;
			string text = decoder.ReadStr8() ;
			Object context = this.SequenceManager.Release(sequence) ;
			
			if (context.Equals(CONTEXT_STARTUP)) {
				broker.DecrementOutstanding() ;
			} else {
			 	if ((context.Equals(CONTEXT_SYNC)) & broker.GetSyncInFlight()) {
					broker.SetSyncInFlight(false) ;
				} else {
					if (context.Equals(CONTEXT_MULTIGET) && SyncSequenceList.Contains(sequence)) {
						lock(LockObject) {
							SyncSequenceList.Remove(sequence) ;
							if (SyncSequenceList.Count == 0) {
								Monitor.PulseAll(LockObject) ;
							}
						}
					}
				}
			}
		}	
Exemplo n.º 6
0
		protected long SendMethodRequest(QMFObject obj, Broker aBroker, string name, List<object> args, bool synchronous, int timeToLive) {
			
			SchemaMethod method = obj.Schema.GetMethod(name) ;
			if (args == null) {
				args = new List<object>() ;
			}
			
			long seq = 0 ;
			if (method != null) {
				KeyValuePair<SchemaMethod, bool> pair = new KeyValuePair<SchemaMethod, bool>(method, synchronous) ;
				seq = SequenceManager.Reserve(pair) ;
				IEncoder enc = aBroker.CreateEncoder('M', seq) ;
				obj.ObjectID.encode(enc) ;
				obj.Schema.Key.encode(enc) ;
				enc.WriteStr8(name) ;
				
				if (args.Count < method.InputArgCount) {
					throw new Exception(String.Format("Incorrect number of arguments: expected {0}, got{1}", method.InputArgCount, args.Count)) ;
				}
				
				int argIndex = 0 ;
				foreach (SchemaArgument arg in method.Arguments) {
					if (arg.IsInput()) {;						
						this.EncodeValue(enc, arg.Type, args[argIndex]) ;
						argIndex += 1 ;
					} 
				}
				
				Message msg = aBroker.CreateMessage(enc,obj.RoutingKey(),timeToLive) ;
				
				if (synchronous) {
					aBroker.SetSyncInFlight(true) ;
				}
				aBroker.Send(msg) ;
			}
			return seq ;
		}