Esempio n. 1
0
		public object DecodeValue(IDecoder dec, short type) {
		
		 	switch (type) {
		 		case 1: return dec.ReadUint8() ;        // U8
		 		case 2: return dec.ReadUint16() ;       // U16     
		 		case 3: return dec.ReadUint32() ;       // U32
		 		case 4: return dec.ReadUint64() ;       // U64 
		 		case 6: return dec.ReadStr8() ;         // SSTR
		 		case 7: return dec.ReadStr16() ;        // LSTR
		 		case 8: return dec.ReadDatetime() ;	    // ABSTIME
		 		case 9: return dec.ReadUint32() ;       // DELTATIME
		 		case 10: return new ObjectID(dec) ;		// ref
		 		case 11: return dec.ReadUint8() != 0 ;  // bool
		 		case 12: return dec.ReadFloat() ;       // float		
		 		case 13: return dec.ReadDouble() ;      // double		 
		 		case 14: return dec.ReadUuid() ;	    // UUID			
		 		case 15: return dec.ReadMap() ;             // Ftable
		 		case 16: return dec.ReadInt8() ;        // int8
		 		case 17: return dec.ReadInt16() ;       // int16    
		 		case 18: return dec.ReadInt32() ;       // int32
		 		case 19: return dec.ReadInt64() ;       // int64 		 			
		 		case 20:                                // Object
		 			// Peek into the inner type code, make sure 
		 			// it is actually an object
		 			object returnValue = null ;
		 			short innerTypeCode = dec.ReadUint8() ;
		 			if (innerTypeCode != 20) {
		 				returnValue = this.DecodeValue(dec, innerTypeCode) ;
		 			}
		 			else {
		 				ClassKey classKey = new ClassKey(dec) ;
		 				lock(LockObject) {
		 					SchemaClass sClass = GetSchema(classKey) ;
		 					if (sClass != null) {
		 						returnValue = this.CreateQMFObject(sClass, dec, true, true, false) ;
		 					}
		 				}
		 			}
		 			return returnValue;
                case 21:                                 // List
		 	        {
		 	            MSDecoder lDec = new MSDecoder();
		 	            lDec.Init(new MemoryStream(dec.ReadVbin32()));
		 	            long count = lDec.ReadUint32();
		 	            List<object> newList = new List<object>();
		 	            while (count > 0)
		 	            {
		 	                short innerType = lDec.ReadUint8();
		 	                newList.Add(this.DecodeValue(lDec, innerType));
		 	                count -= 1;
		 	            }
		 	            return newList;
		 	        }
                case 22:							    // Array
		 	        {
		 	            MSDecoder aDec = new MSDecoder();
		 	            aDec.Init(new MemoryStream(dec.ReadVbin32()));
		 	            long cnt = aDec.ReadUint32();
		 	            short innerType = aDec.ReadUint8();
		 	            List<object> aList = new List<object>();
		 	            while (cnt > 0)
		 	            {
		 	                aList.Add(this.DecodeValue(aDec, innerType));
		 	                cnt -= 1;
		 	            }
		 	            return aList;
		 	        }
		 	    default: 
		 			throw new Exception(String.Format("Invalid Type Code: {0}", type)) ;		
		 	}	
		 }		
Esempio n. 2
0
		public void MessageTransfer(IMessage msg) {
			MSDecoder decoder = new MSDecoder() ;
			decoder.Init(msg.Body) ;
			RangeSet rangeSet = new RangeSet() ;
			rangeSet.Add(msg.Id) ;
			char opcode = 'x' ;
			long seq = -1 ;
			while (this.CheckHeader(decoder, out opcode, out seq)) {
				//log.Debug("Message recieved with opcode " + opcode + " and sequence " + seq) ;
				//log.Debug(System.Text.Encoding.UTF8.GetString(msg.Body.ToArray())) ;
				switch (opcode) {
					case 'b':
						consoleSession.HandleBrokerResponse(this, decoder, seq) ;
						break ;
					case 'p':
						consoleSession.HandlePackageIndicator(this, decoder, seq) ;
						break ;		
					case 'z':
						consoleSession.HandleCommandComplete(this, decoder, seq) ;
						break ;		
					case 'q':
						consoleSession.HandleClassIndicator(this, decoder, seq) ;
						break ;			
					case 'm':
						consoleSession.HandleMethodResponse(this, decoder, seq) ;
						break ;							
					case 'h':
						consoleSession.HandleHeartbeatIndicator(this, decoder, seq, msg) ;
						break ;						
					case 'e':
						consoleSession.HandleEventIndicator(this, decoder, seq) ;
						break ;							
					case 's':
						consoleSession.HandleSchemaResponse(this, decoder, seq) ;
						break ;			
					case 'c':
						consoleSession.HandleContentIndicator(this, decoder, seq, true, false) ;
						break ;	
					case 'i':
						consoleSession.HandleContentIndicator(this, decoder, seq, false, true) ;
						break ;		
					case 'g':
						consoleSession.HandleContentIndicator(this, decoder, seq, true, true) ;
						break ;			
					default:
						log.Error("Invalid message type recieved with opcode " + opcode) ;
						break ;
				}		
			} 
			lock (lockObject) {
				outSession.MessageAccept(rangeSet) ;
			}
		}