Example #1
0
bool Header::GetFromVariant(Header &header, Variant &variant) {
	if (variant != V_MAP) {
		FATAL("Variant is not a map: %s", STR(variant.ToString()));
		return false;
	}

	if ((variant[RM_HEADER_HEADERTYPE] != _V_NUMERIC) ||
			(variant[RM_HEADER_CHANNELID] != _V_NUMERIC) ||
			(variant[RM_HEADER_TIMESTAMP] != _V_NUMERIC) ||
			(variant[RM_HEADER_MESSAGELENGTH] != _V_NUMERIC) ||
			(variant[RM_HEADER_MESSAGETYPE] != _V_NUMERIC) ||
			(variant[RM_HEADER_STREAMID] != _V_NUMERIC) ||
			(variant[RM_HEADER_ISABSOLUTE] != V_BOOL)
			) {
		FATAL("Variant is not a valid RTMP header: %s", STR(variant.ToString()));
		return false;
	}

	header.ht = (uint8_t) variant[RM_HEADER_HEADERTYPE];
	header.ci = (uint32_t) variant[RM_HEADER_CHANNELID];
	header.hf.s.ts = (uint32_t) variant[RM_HEADER_TIMESTAMP];
	header.hf.s.ml = (uint32_t) variant[RM_HEADER_MESSAGELENGTH];
	header.hf.s.mt = (uint8_t) variant[RM_HEADER_MESSAGETYPE];
	header.hf.s.si = (uint32_t) variant[RM_HEADER_STREAMID];
	header.readCompleted = true;
	header.isAbsolute = (bool) variant[RM_HEADER_ISABSOLUTE];

	return true;
}
Example #2
0
/// Compares two variants
/// Returns:
///    -1 if a < b
///    1 if a > b
///    0 if a == b
int VariantBase::Compare( const Variant& a, const Variant& b ) {
	int ret;

	if ( a->IsBool() || b->IsBool() ) {
		ret = basicComparison<int>( a->AsBool(), b->AsBool() );
	}
	else if ( a->IsNumber() || b->IsNumber() ) {
		ret = VarNumeric::Compare( a->ToNumber(), b->ToNumber() );
	}
	else {
		ret = VarString::Compare( a->ToString(), b->ToString() );
	}

	return( ret );
}
Example #3
0
CString PropertyAccess::DisplayTextFromIdAndValue(unsigned int propId, Variant value)
{
   // TODO implement
   propId;

   return value.ToString();
}
Example #4
0
void JSONValue::SetVectorVariant(const String& name, const Variant& value)
{
    VariantType type = value.GetType();
    if (type == VAR_FLOAT || type == VAR_VECTOR2 || type == VAR_VECTOR3 || type == VAR_VECTOR4 || type == VAR_MATRIX3 ||
        type == VAR_MATRIX3X4 || type == VAR_MATRIX4)
        SetString(name, value.ToString());
}
Example #5
0
void JSONValue::AddVectorVariant(const Variant& value)
{
    VariantType type = value.GetType();
    if (type == VAR_FLOAT || type == VAR_VECTOR2 || type == VAR_VECTOR3 || type == VAR_VECTOR4 || type == VAR_MATRIX3 ||
        type == VAR_MATRIX3X4 || type == VAR_MATRIX4)
        AddString(value.ToString());
}
bool RTMPProtocolSerializer::SerializeInvoke(IOBuffer &buffer,
		Variant &message) {

	string functionName = message[RM_INVOKE_FUNCTION];
	if (!_amf0.WriteShortString(buffer, functionName)) {
		FATAL("Unable to write %s", STR(RM_INVOKE_FUNCTION));
		return false;
	}

	if (!_amf0.WriteDouble(buffer, message[RM_INVOKE_ID])) {
		FATAL("Unable to write %s", STR(RM_INVOKE_ID));
		return false;
	}

	FOR_MAP(message[RM_INVOKE_PARAMS], string, Variant, i) {
		if (!_amf0.Write(buffer, MAP_VAL(i))) {
			FATAL("Unable to serialize invoke parameter %s: %s",
					STR(MAP_KEY(i)),
					STR(message.ToString()));
			return false;
		}
	}

	return true;
}
bool OutboundRTMPProtocol::SignalProtocolCreated(BaseProtocol *pProtocol,
		Variant customParameters) {
	//1. Get the application  designated for the newly created connection
	if (customParameters[CONF_APPLICATION_NAME] != V_STRING) {
		FATAL("connect parameters must have an application name");
		return false;
	}
	BaseClientApplication *pApplication = ClientApplicationManager::FindAppByName(
			customParameters[CONF_APPLICATION_NAME]);
	if (pApplication == NULL) {
		FATAL("Application %s not found", STR(customParameters[CONF_APPLICATION_NAME]));
		return false;
	}

	if (pProtocol == NULL) {
		FATAL("Connection failed:\n%s", STR(customParameters.ToString()));
		return pApplication->OutboundConnectionFailed(customParameters);
	}

	//2. Set the application
	pProtocol->SetApplication(pApplication);


	//3. Trigger processing, including handshake
	OutboundRTMPProtocol *pOutboundRTMPProtocol = (OutboundRTMPProtocol *) pProtocol;
	pOutboundRTMPProtocol->SetOutboundConnectParameters(customParameters);
	IOBuffer dummy;
	return pOutboundRTMPProtocol->SignalInputData(dummy);
}
bool BaseAppProtocolHandler::PullExternalStream(URI uri, Variant streamConfig)
{
    WARN("Pulling in streams for scheme %s in application %s not yet implemented. Stream configuration was:\n%s",
         STR(uri.scheme()),
         STR(GetApplication()->GetName()),
         STR(streamConfig.ToString()));
    return false;
}
Example #9
0
bool XMLElement::SetVectorVariant(const String& name, const Variant& value)
{
    VariantType type = value.GetType();
    if (type == VAR_FLOAT || type == VAR_VECTOR2 || type == VAR_VECTOR3 || type == VAR_VECTOR4)
        return SetAttribute(name, value.ToString());
    else
        return false;
}
Example #10
0
bool EvalLuaExpression(lua_State *pLuaState, string expression) {
	if (luaL_dostring(pLuaState, STR("return " + expression)) != 0) {
		Variant v;
		PopStack(pLuaState, v);
		FATAL("Unable to evaluate expression %s\n%s", STR(expression), STR(v.ToString()));
		return false;
	}
	return true;
}
bool BaseVariantAppProtocolHandler::SignalProtocolCreated(BaseProtocol *pProtocol, Variant &parameters) {
	//1. Get the application
	BaseClientApplication *pApplication = ClientApplicationManager::FindAppByName(
			parameters["applicationName"]);
	if (pApplication == NULL) {
		FATAL("Unable to find application %s",
				STR(parameters["applicationName"]));
		return false;
	}

	//2. get the protocol handler
	BaseAppProtocolHandler *pHandler = pApplication->GetProtocolHandler(PT_BIN_VAR);
	if (pHandler == NULL) {
		pHandler = pApplication->GetProtocolHandler(PT_XML_VAR);
		if (pHandler == NULL) {
			WARN("Unable to get protocol handler for variant protocol");
		}
	}


	//3. Is the connection up
	if (pProtocol == NULL) {
		if (pHandler != NULL) {
			((BaseVariantAppProtocolHandler *) pHandler)->ConnectionFailed(parameters);
		} else {
			WARN("Connection failed:\n%s", STR(parameters.ToString()));
		}
		return false;
	}

	//1. Validate the protocol
	if (pProtocol->GetType() != PT_BIN_VAR &&
			pProtocol->GetType() != PT_XML_VAR) {
		FATAL("Invalid protocol type. Wanted: %s or %s; Got: %s",
				STR(tagToString(PT_BIN_VAR)),
				STR(tagToString(PT_XML_VAR)),
				STR(tagToString(pProtocol->GetType())));
		return false;
	}

	//3. Register the protocol to it
	pProtocol->SetApplication(pApplication);

	if (pProtocol->GetFarProtocol() == NULL) {
		FATAL("Invalid far protocol");
		return false;
	}

	//4. Do the actual request
	if (pProtocol->GetFarProtocol()->GetType() == PT_TCP) {
		return ((BaseVariantProtocol *) pProtocol)->Send(parameters["payload"]);
	} else {
		return ((BaseVariantProtocol *) pProtocol)->Send(parameters);
	}
}
Example #12
0
int BaseVMLua::GetFunctionReference(string path) {
	if (luaL_dostring(_pGlobalState, STR("return " + path)) != 0) {
		Variant v;
		PopStack(_pGlobalState, v);
		FATAL("Unable to get path %s\n%s", STR(path), STR(v.ToString()));
		return 0;
	}
	if (lua_type(_pGlobalState, -1) != LUA_TFUNCTION) {
		FATAL("Path %s is not a lua function", STR(path));
		lua_pop(_pGlobalState, 1);
		return 0;
	}
	int result = luaL_ref(_pGlobalState, LUA_REGISTRYINDEX);
	if (result < 0) {
		Variant v;
		PopStack(_pGlobalState, v);
		FATAL("Unable to get reference\n%s", STR(v.ToString()));
		return 0;
	}

	return result;
}
Example #13
0
bool XMLElement::SetVariantValue(const Variant& value)
{
    switch (value.GetType())
    {
    case VAR_RESOURCEREF:
        return SetResourceRef(value.GetResourceRef());

    case VAR_RESOURCEREFLIST:
        return SetResourceRefList(value.GetResourceRefList());

    case VAR_VARIANTVECTOR:
        return SetVariantVector(value.GetVariantVector());

    case VAR_VARIANTMAP:
        return SetVariantMap(value.GetVariantMap());

    default:
        return SetAttribute("value", value.ToString().CString());
    }
}
Example #14
0
void JSONValue::AddVariantValue(const Variant& value)
{
    switch (value.GetType())
    {
    case VAR_RESOURCEREF:
        AddResourceRef(value.GetResourceRef());
        break;

    case VAR_RESOURCEREFLIST:
        AddResourceRefList(value.GetResourceRefList());
        break;

    case VAR_VARIANTVECTOR:
    case VAR_VARIANTMAP:
        LOGERROR("Unsupported value type");
        break;

    default:
        AddString(value.ToString());
    }
}
Variant GetDPByExpExpression::Evaluate(Expressive::EvalContext* context)
{
	Object* obj = m_object->Evaluate(context);
	DependencyObject* depObj = dynamic_cast<DependencyObject*>(obj);
	if (depObj == NULL)
	{
		VERIFY(0);
	}
	Variant propertyRef = m_exp->Evaluate(context);

	PropertyValue* pProperty;

	if (propertyRef.IsString())
		pProperty = depObj->GetProperty(depObj->GetClass()->GetLocalProperty(propertyRef.ToString()));
	else if (propertyRef.IsInt())
		pProperty = depObj->GetProperty(depObj->GetClass()->GetLocalProperty((int)propertyRef));
	else
		throw new Exception("property not found");

	return pProperty->GetComputedValue();
}
bool GetDPByExpExpression::Set(Expressive::EvalContext* context, Variant value)
{
	Object* obj = m_object->Evaluate(context);
	DependencyObject* depObj = dynamic_cast<DependencyObject*>(obj);
	if (depObj == NULL)
	{
		VERIFY(0);
	}
	Variant propertyRef = m_exp->Evaluate(context);

	PropertyValue* pProperty;

	if (propertyRef.IsString())
		pProperty = depObj->GetProperty(depObj->GetClass()->GetLocalProperty(propertyRef.ToString()));
	else if (propertyRef.IsInt())
		pProperty = depObj->GetProperty(depObj->GetClass()->GetLocalProperty(int(propertyRef)));
	else
		raise(Exception("property not found"));

	pProperty->UpdateValue(value);
	return true;
}
bool UDSCommandAppProtocolHandler::OnMessage(BaseUDSMessageProtocol *pProtocol, Variant &message)
{
  if(!message.HasKey("type") && !message.HasKey("id")) {
    FATAL("Unable to get message type or thread id\n%s", STR(message.ToString()));
    return false;
  }
  if(((uint8_t)message["type"]) == UDSCommandThread::MM_THREAD_CREATED) {
    uint32_t threadId = (uint32_t) message["id"];
    UDSCommandThread *pThread = (UDSCommandThread*)ThreadManager::FindThreadById(threadId);
    if(pThread == NULL) {
      FATAL("Unable to find thread by id(%d)", threadId);
      return false;
    }
    pThread->SetUDSMessageProtocol(pProtocol);
    ThreadManager::EnqueueThread(pThread->GetType(), pThread);
    //INFO("set protocol");
    //pThread->SetUDSMessageProtocol(pProtocol);
  }else{
    FATAL("Unable to handle this message type");
    return false;
  }
  return true;
}
void DebugHud::SetAppStats(const String& label, const Variant& stats)
{
    SetAppStats(label, stats.ToString());
}
bool BaseVariantAppProtocolHandler::ProcessMessage(BaseVariantProtocol *pProtocol,
		Variant &lastSent, Variant &lastReceived) {
	FINEST("lastSent:\n%s", STR(lastSent.ToString()));
	FINEST("lastReceived:\n%s", STR(lastReceived.ToString()));
	return true;
}
Example #20
0
bool ProcessInstance::SetParameterValue( const Variant& value,
                                         const ProcessParameter& parameter, size_type rowIndex )
{
   if ( !value.IsValid() )
      return false;

   uint32 apiType = (*API->Process->GetParameterType)( parameter.Handle() ) & PTYPE_TYPE_MASK;
   if ( apiType == 0 )
      throw APIFunctionError( "GetParameterType" );

   if ( apiType == PTYPE_TABLE )
      throw Error( "ProcessInstance::SetParameterValue(): Invoked for a table parameter" );

   if ( apiType == PTYPE_STRING )
   {
      String s = value.ToString();
      return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, s.c_str(), s.Length() ) != api_false;
   }

   if ( apiType == PTYPE_BLOCK )
   {
      ByteArray a = value.ToByteArray();
      return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, a.Begin(), a.Length() ) != api_false;
   }

   union
   {
      uint32   u32;
      int32    i32;
      uint64   u64;
      int64    i64;
      float    f;
      double   d;
      api_bool b;
      api_enum e;
   }
   apiValue;

   switch ( apiType )
   {
   case PTYPE_UINT8:
   case PTYPE_UINT16:
   case PTYPE_UINT32:
      apiValue.u32 = value.ToUInt();
      break;
   case PTYPE_INT8:
   case PTYPE_INT16:
   case PTYPE_INT32:
      apiValue.i32 = value.ToInt();
      break;
   case PTYPE_UINT64:
      apiValue.u64 = value.ToUInt64();
      break;
   case PTYPE_INT64:
      apiValue.i64 = value.ToInt64();
      break;
   case PTYPE_FLOAT:
      apiValue.f = value.ToFloat();
      break;
   case PTYPE_DOUBLE:
      apiValue.d = value.ToDouble();
      break;
   case PTYPE_BOOL:
      apiValue.b = api_bool( value.ToBoolean() );
      break;
   case PTYPE_ENUM:
      apiValue.e = api_enum( value.ToInt() );
      break;
   default:
      throw Error( "ProcessParameter::SetParameterValue(): Internal error: Unknown parameter type" );
   }

   return (*API->Process->SetParameterValue)( handle, parameter.Handle(), rowIndex, &apiValue, 1 ) != api_false;
}
Example #21
0
bool InboundHTTP4RTMP::SignalInputData(IOBuffer &buffer) {
	//1. Get the HTTP far protool and test to see if it has ContentLength
	InboundHTTPProtocol *pHTTP = (InboundHTTPProtocol *) _pFarProtocol;
	if (pHTTP == NULL || pHTTP->GetContentLength() == 0) {
		FATAL("Invalid HTTP request");
		return false;
	}

	//2. Test it and see if all the data was transfered
	if (!pHTTP->TransferCompleted()) {
		return true;
	}

	//3. Get the HTTP request
	Variant request = pHTTP->GetHeaders();

	//4. Is this a keep-alive?
	pHTTP->SetDisconnectAfterTransfer(
			request[HTTP_HEADERS][HTTP_HEADERS_CONNECTION]
			!= HTTP_HEADERS_CONNECTION_KEEP_ALIVE);
	DeleteNearProtocol(false);

	//4. Get the URL
	string url = request[HTTP_FIRST_LINE][HTTP_URL];

	//5. split it in meaningful parts
	vector<string> parts;
	split(url, "/", parts);
	if (parts.size() < 2) {
		FATAL("Invalid request:\n%s", STR(request.ToString()));
		return false;
	}

	//7. Do the dammage
	bool result;
	if (parts[1] == "fcs") {
		result = ProcessFcs(parts);
		buffer.Ignore(pHTTP->GetContentLength());
	} else if (parts[1] == "open") {
		result = ProcessOpen(parts);
		buffer.Ignore(pHTTP->GetContentLength());
	} else if (parts[1] == "idle") {
		result = ProcessIdle(parts);
		buffer.Ignore(pHTTP->GetContentLength());
	} else if (parts[1] == "send") {
		if (GETAVAILABLEBYTESCOUNT(buffer) < 1)
			return false;
		_inputBuffer.ReadFromBuffer(GETIBPOINTER(buffer), pHTTP->GetContentLength());
		buffer.Ignore(pHTTP->GetContentLength());
		result = ProcessSend(parts);
	} else {
		FATAL("Invalid command: %s", STR(parts[1]));
		result = false;
	}

	//8. Cleanup
	if (!result) {
		DeleteNearProtocol(true);
		EnqueueForDelete();
	}

	//9. Done
	return result;
}
Example #22
0
bool BaseInFileStream::ResolveCompleteMetadata(Variant &metaData) {
	if ((bool)metaData[CONF_APPLICATION_EXTERNSEEKGENERATOR])
		return false;
	//1. Create the document
	BaseMediaDocument *pDocument = NULL;
	if (false) {

	}
#ifdef HAS_MEDIA_FLV
	else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_FLV ||
			metaData[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) {
		pDocument = new FLVDocument(metaData);
	}
#endif /* HAS_MEDIA_FLV */
#ifdef HAS_MEDIA_MP3
	else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP3) {
		pDocument = new MP3Document(metaData);
	}
#endif /* HAS_MEDIA_MP3 */
#ifdef HAS_MEDIA_MP4
	else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP4
			|| metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4A
			|| metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4V
			|| metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MOV
			|| metaData[META_MEDIA_TYPE] == MEDIA_TYPE_F4V) {
		pDocument = new MP4Document(metaData);
	}
#endif /* HAS_MEDIA_MP4 */
#ifdef HAS_MEDIA_NSV
	else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_NSV) {
		pDocument = new NSVDocument(metaData);
	}
#endif /* HAS_MEDIA_NSV */

	else {
		FATAL("File type not supported yet. Partial metadata:\n%s",
				STR(metaData.ToString()));
		return false;
	}

	//2. Process the document
	FINEST("Processing file %s", STR(metaData[META_SERVER_FULL_PATH]));
	if (!pDocument->Process()) {
		FATAL("Unable to process document");
		delete pDocument;
		if ((bool)metaData[CONF_APPLICATION_RENAMEBADFILES]) {
			moveFile(metaData[META_SERVER_FULL_PATH],
					(string) metaData[META_SERVER_FULL_PATH] + ".bad");
		} else {
			WARN("File %s will not be renamed",
					STR(metaData[META_SERVER_FULL_PATH]));
		}
		return false;
	}

	//3. Get the medatada
	metaData = pDocument->GetMetadata();

	//4. cleanup
	delete pDocument;

	//5. Done
	return true;
}
Example #23
0
void JSONValue::SetVariantValue(const Variant& variant, Context* context)
{
    if (!IsNull())
    {
        LOGWARNING("JsonValue is not null");
    }

    switch (variant.GetType())
    {
    case VAR_BOOL:
        *this = variant.GetBool();
        return;
    
    case VAR_INT:
        *this = variant.GetInt();
        return;

    case VAR_FLOAT:
        *this = variant.GetFloat();
        return;

    case VAR_DOUBLE:
        *this = variant.GetDouble();
        return;

    case VAR_STRING:
        *this = variant.GetString();
        return;

    case VAR_VARIANTVECTOR:
        SetVariantVector(variant.GetVariantVector(), context);
        return;

    case VAR_VARIANTMAP:
        SetVariantMap(variant.GetVariantMap(), context);
        return;

    case VAR_RESOURCEREF:
        {
            if (!context)
            {
                LOGERROR("Context must not null for ResourceRef");
                return;
            }

            const ResourceRef& ref = variant.GetResourceRef();
            *this = String(context->GetTypeName(ref.type_)) + ";" + ref.name_;
        }
        return;

    case VAR_RESOURCEREFLIST:
        {
            if (!context)
            {
                LOGERROR("Context must not null for ResourceRefList");
                return;
            }

            const ResourceRefList& refList = variant.GetResourceRefList();
            String str(context->GetTypeName(refList.type_));
            for (unsigned i = 0; i < refList.names_.Size(); ++i)
            {
                str += ";";
                str += refList.names_[i];
            }
            *this = str;
        }
        return;

    case VAR_STRINGVECTOR:
        {
            const StringVector& vector = variant.GetStringVector();
            Resize(vector.Size());
            for (unsigned i = 0; i < vector.Size(); ++i)
                (*this)[i] = vector[i];
        }
        return;

    default:
        *this = variant.ToString();
    }
}
bool RTMPProtocolSerializer::Serialize(Channel &channel,
		Variant &message, IOBuffer &buffer, uint32_t chunkSize) {
	bool result = false;
	_internalBuffer.Ignore(GETAVAILABLEBYTESCOUNT(_internalBuffer));

	switch ((uint32_t) VH_MT(message)) {
		case RM_HEADER_MESSAGETYPE_INVOKE:
		{
			result = SerializeInvoke(_internalBuffer, message[RM_INVOKE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_NOTIFY:
		{
			result = SerializeNotify(_internalBuffer, message[RM_NOTIFY]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_FLEXSTREAMSEND:
		{
			result = SerializeFlexStreamSend(_internalBuffer, message[RM_FLEXSTREAMSEND]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_FLEXSHAREDOBJECT:
		{
			result = SerializeFlexSharedObject(_internalBuffer, message[RM_SHAREDOBJECT]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_SHAREDOBJECT:
		{
			result = SerializeSharedObject(_internalBuffer, message[RM_SHAREDOBJECT]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_ACK:
		{
			result = SerializeAck(_internalBuffer, message[RM_ACK]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_USRCTRL:
		{
			result = SerializeUsrCtrl(_internalBuffer, message[RM_USRCTRL]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_CHUNKSIZE:
		{
			result = SerializeChunkSize(_internalBuffer, message[RM_CHUNKSIZE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_WINACKSIZE:
		{
			result = SerializeWinAckSize(_internalBuffer, message[RM_WINACKSIZE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_PEERBW:
		{
			result = SerializeClientBW(_internalBuffer, message[RM_PEERBW]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_ABORTMESSAGE:
		{
			result = SerializeAbortMessage(_internalBuffer, message[RM_ABORTMESSAGE]);
			break;
		}
		default:
		{
			FATAL("Invalid message type:\n%s", STR(message.ToString()));
		}
	}

	//2. Check out the result
	if (!result) {
		FATAL("Unable to serialize message body");
		return false;
	}

	//3. Update the message length
	VH_ML(message) = GETAVAILABLEBYTESCOUNT(_internalBuffer);

	//4. Extract the header
	Header header;
	if (!Header::GetFromVariant(header, message[RM_HEADER])) {
		FATAL("Unable to read RTMP header: %s", STR(message.ToString()));
		return false;
	}

	//5. Chunk and send the data
	uint32_t available = 0;
	while ((available = GETAVAILABLEBYTESCOUNT(_internalBuffer)) != 0) {
		if (!header.Write(channel, buffer)) {
			FATAL("Unable to serialize message header");
			result = false;
		}
		if (available >= chunkSize) {
			buffer.ReadFromInputBuffer(&_internalBuffer, 0, chunkSize);
			channel.lastOutProcBytes += chunkSize;
			_internalBuffer.Ignore(chunkSize);
		} else {
			buffer.ReadFromInputBuffer(&_internalBuffer, 0, available);
			channel.lastOutProcBytes += available;
			_internalBuffer.Ignore(available);
		}
	}
	channel.lastOutProcBytes = 0;

	//6. Done
	return result;
}
 void DataChange(uint32_t handle, const Node& node, const Variant& val, AttributeId attr) override
 {
   std::cout << "Received DataChange event, value of Node " << node << " is now: "  << val.ToString() << std::endl;
 }
Example #26
0
//-----------------------------------------------------------------------------------------------------------------------------------------------------
String Node::GetValue()
{
	Variant Value;
	VerifyComResult(m_pNode->get_nodeValue(&Value));
	return Value.ToString();
}
void BaseVariantAppProtocolHandler::ConnectionFailed(Variant &parameters) {
	WARN("Connection failed:\n%s", STR(parameters.ToString()));
}