コード例 #1
0
ファイル: Server.cpp プロジェクト: kkskipper/KNOWME
void CServer::StartL()
    {
	// Create a thread for a MessageQueue

// check sim card
//	if(Util::IsNetworkAvaiable())
//		{
	TRequestStatus theadRendezvousStatus;	
	RThread messageQueueThread;
	User::LeaveIfError(messageQueueThread.Create(KExecMsgThreadBaseName, CServer::MessageQueueThreadFunc,
			KStackSize, NULL, this));
	messageQueueThread.SetPriority(EPriorityMuchLess);
	messageQueueThread.Rendezvous(theadRendezvousStatus); 	
	messageQueueThread.Resume();
	// wait for launch to complete
	User::WaitForRequest(theadRendezvousStatus);
	messageQueueThread.Close();
//		}

	TBuf8<KConfigLength> modelName;
	iProp->OpenDBL();
	iProp->GetConfigL(KUserSection, KModel, modelName);
	iProp->CloseDB();

	
	if(modelName.Length()>0)
		{
		TRequestStatus theadRendezvousStatus;			
		RThread sedentaryThread;
		User::LeaveIfError(sedentaryThread.Create(KExecSedentaryThreadBaseName, CServer::SedentaryThreadFunc,
				KStackSize, NULL, this));
		sedentaryThread.SetPriority(EPriorityMuchLess);
		sedentaryThread.Rendezvous(theadRendezvousStatus); 	
		sedentaryThread.Resume();
		User::WaitForRequest(theadRendezvousStatus);
		sedentaryThread.Close();
		}

	// Create Collector & Sensor Instances
	for (int i = 0; i < iProp->iNodeArray.Count(); i++)
        {
        TNode* node = iProp->iNodeArray[i];
		node->StartL();
        };

	
	if(iSedentary!=NULL)
		{
		TBuf8<KConfigLength> sedentaryStart;
		iProp->OpenDBL();
		iProp->GetConfigL(KSystemSection, KSedentary, sedentaryStart);
		iProp->CloseDB();
		
		if(sedentaryStart[0]=='1')
			{
			StartSendentary();
			}
		}
	
	
    // create a thread for a MessageQueue
	ListenL();
    }
コード例 #2
0
// -----------------------------------------------------------------------------
// CSeiForwardPlugin::HandleNotifyL
// 
// -----------------------------------------------------------------------------
//
void CSeiForwardPlugin::HandleNotifyL( const CEcmtMessageEvent& aEvent )
	{
    const TPtrC8 m = iMessaging->Message( aEvent );

    TLex8 lexer( m );
    TPtrC8 type = lexer.NextToken();
    TPtrC8 channelStr = lexer.NextToken();
	TLex8 num ( channelStr );
	TInt channel;
	
	// Check message type	
	
    if ( ( type != KConnect ) &&
         ( type != KListen ) && 
         ( type != KMsg ) )
        {
		RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid message" ) );
        return;
        }

	// Get channel number

	if ( num.Val( channel ) ) 
		{
		RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid channel" ) );
        return;
		}

	// Process message

	if ( type == KConnect ) 
		{
		TPtrC8 portStr = lexer.NextToken();
		TInt port;
		
		num.Assign ( portStr );
		
		// Get port number
		
		if ( num.Val( port ) ) 
			{
			RDebug::Print( _L( "EcmtSeiForwardPlugin: Invalid port" ) );
        	return;
			}
		
		ConnectL( channel, port );
		}
	else if ( type == KListen )
		{
		ListenL( channel );
		}
	else if ( type == KMsg )
		{
		// Now this just sends the message back to the Java plug-in.		
		// Instead, should cancel the appropriate socket read and write
		// the message to the socket.
		
		TPtrC8 msg = lexer.Remainder();
		
		SendMessageL( channel, msg );
		}
	}