Ejemplo n.º 1
0
Ticket TransportLayerMock::sourceMessage(Session& session, Message* message, Date_t expiration) {
    if (inShutdown()) {
        return Ticket(TransportLayer::ShutdownStatus);
    } else if (!owns(session.id())) {
        return Ticket(TransportLayer::SessionUnknownStatus);
    } else if (session.ended()) {
        return Ticket(Session::ClosedStatus);
    }

    return Ticket(this,
                  stdx::make_unique<TransportLayerMock::TicketMock>(&session, message, expiration));
}
Ejemplo n.º 2
0
Ticket TransportLayerMock::sinkMessage(const SessionHandle& session,
                                       const Message& message,
                                       Date_t expiration) {
    if (inShutdown()) {
        return Ticket(TransportLayer::ShutdownStatus);
    } else if (!owns(session->id())) {
        return Ticket(TransportLayer::SessionUnknownStatus);
    } else if (_sessions[session->id()].ended) {
        return Ticket(TransportLayer::TicketSessionClosedStatus);
    }

    return Ticket(this, stdx::make_unique<transport::MockTicket>(session, expiration));
}
Ejemplo n.º 3
0
Ticket TransportLayerLegacy::sinkMessage(const SessionHandle& session,
                                         const Message& message,
                                         Date_t expiration) {
    auto& compressorMgr = session->getCompressorManager();
    auto sinkCb = [&message, &compressorMgr](AbstractMessagingPort* amp) -> Status {
        try {
            networkCounter.hitLogical(0, message.size());
            auto swm = compressorMgr.compressMessage(message);
            if (!swm.isOK())
                return swm.getStatus();
            const auto& compressedMessage = swm.getValue();
            amp->say(compressedMessage);
            networkCounter.hitPhysical(0, compressedMessage.size());

            return Status::OK();
        } catch (const SocketException& e) {
            return {ErrorCodes::HostUnreachable, e.what()};
        }
    };

    auto legacySession = checked_pointer_cast<LegacySession>(session);
    return Ticket(
        this,
        stdx::make_unique<LegacyTicket>(std::move(legacySession), expiration, std::move(sinkCb)));
}
Ejemplo n.º 4
0
Ticket TransportLayerLegacy::sourceMessage(const SessionHandle& session,
                                           Message* message,
                                           Date_t expiration) {
    auto& compressorMgr = session->getCompressorManager();
    auto sourceCb = [message, &compressorMgr](AbstractMessagingPort* amp) -> Status {
        if (!amp->recv(*message)) {
            return {ErrorCodes::HostUnreachable, "Recv failed"};
        }

        networkCounter.hitPhysical(message->size(), 0);
        if (message->operation() == dbCompressed) {
            auto swm = compressorMgr.decompressMessage(*message);
            if (!swm.isOK())
                return swm.getStatus();
            *message = swm.getValue();
        }
        networkCounter.hitLogical(message->size(), 0);
        return Status::OK();
    };

    auto legacySession = checked_pointer_cast<LegacySession>(session);
    return Ticket(
        this,
        stdx::make_unique<LegacyTicket>(std::move(legacySession), expiration, std::move(sourceCb)));
}
Ejemplo n.º 5
0
void Database::sellTicket(string eventId, string personName)
{
	int i,sizex,seats;
	bool doesExist=false;

	sizex=tickets.size();					//get the size of list

	try{
		for(i=0;i<sizex;i++)
			if(personName==tickets[i].getOwnerName()&&eventId==tickets[i].getEventId())
			{	
				seats=tickets[i].getNumberOfSeats();
					
				//if ticket is found, erase the relevant entry and indicate as bool
			
				tickets.erase(tickets.begin()+i,tickets.begin()+i+1);
				tickets.push_back(Ticket (eventId,personName,seats,false));
						
				//and add again as a ticket
				doesExist=true;


			}
		if(!doesExist)
			throw (SystemError) 7;
	}
	catch(SystemError x) {
		cout << "ERR_TICKET_CUSTOMER_NOT_EXISTS"<<endl;
	}
}				
Ejemplo n.º 6
0
Ticket MessageManager::StartConversation(int socketFD)
{
	Lock lock(&m_endpointsMutex);

	//If the endpoint doesn't exist, then it was closed. Just exit with failure
	if(m_endpoints.count(socketFD) == 0)
	{
		return Ticket();
	}

	Lock rwLock(m_endpoints[socketFD].second, READ_LOCK);
	if(m_endpoints[socketFD].first == NULL)
	{
		return Ticket();
	}

	return Ticket(m_endpoints[socketFD].first->StartConversation(), 0, false, false, socketFD, m_endpoints[socketFD].second);
}
Ejemplo n.º 7
0
// enqueues a new ticket at the back of the ticket queue and returns true
// ticketid is assigned automatically as 1+maxticketid if enqueueing is possible
// does not enqueue and returns false if either parameter is empty string
// POST:  new ticket with supplied parameters is added to back of tickets,
//        maxticketid is incremented
// PARAM: customer and complaint fields to pass to Ticket constructor
bool CCQueue::Add(string customer, string complaint)
{
	if (customer.length() == 0 || complaint.length() == 0)
	{
		return false;
	}
	else
	{
		Ticket NewTicket = Ticket(maxticketid + 1, customer, complaint);

		tickets.InsertBack(NewTicket);

		maxticketid++;
		return true;
	}
}
Ejemplo n.º 8
0
Ticket TransportLayerLegacy::sourceMessage(const SessionHandle& session,
                                           Message* message,
                                           Date_t expiration) {
    auto sourceCb = [message](AbstractMessagingPort* amp) -> Status {
        if (!amp->recv(*message)) {
            return {ErrorCodes::HostUnreachable, "Recv failed"};
        }

        networkCounter.hitPhysicalIn(message->size());
        return Status::OK();
    };

    auto legacySession = checked_pointer_cast<LegacySession>(session);
    return Ticket(
        this,
        stdx::make_unique<LegacyTicket>(std::move(legacySession), expiration, std::move(sourceCb)));
}
Ejemplo n.º 9
0
void Database::reserveTicket(string eventId, string personName, int numSeats)
{
	int i,sizex,totalSeat=0,maxSeats;
	vector<Ticket> ticketList;
	bool doesExist=false;

	ticketList=getEventTickets(eventId);				//choose tickets belongs to eventId
	sizex=ticketList.size();					//get the size of list
	

	try{
		for(i=0;i<sizex;i++)
			if(personName!=ticketList[i].getOwnerName())		//if ownernames are different
				totalSeat+=ticketList[i].getNumberOfSeats();	//calculate occupied seats
			
			else throw (SystemError) 6;							//if they are same throw existence exception
				
		if(totalSeat)
		{	
			maxSeats=getPlace(getEvent(eventId).getPlaceName()).getMaxSeats();
			if(totalSeat + numSeats > maxSeats)	//if there aren't enough place throw an error
				throw (SystemError) 5;
		}
		else 
		{
			sizex=places.size();				//getting size of event vector
			for(i=0; i<sizex; i++)				//find the placeName if it exists
				if(eventId==events[i].getEventId())
				{	
					doesExist=true;		
					break;
				}
			if(!doesExist)			//if place does not exist
				throw (SystemError) 3;	//throw an existance exception
		}
		tickets.push_back(Ticket(eventId,personName,numSeats,true));	//add new ticket object

	}
	catch(SystemError x) {
		if(x==3) cout << "ERR_EVENT_NOT_EXISTS"<<endl; 
		if(x==5) cout << "ERR_NOT_ENOUGH_SEATS"<<endl;		
		if(x==6) cout << "ERR_TICKET_CUSTOMER_EXISTS"<<endl;
	
	}
	ticketList.clear();			//deleting the vector, and cleaning the buffer
}
Ejemplo n.º 10
0
Ticket TransportLayerLegacy::sinkMessage(const SessionHandle& session,
                                         const Message& message,
                                         Date_t expiration) {
    auto sinkCb = [&message](AbstractMessagingPort* amp) -> Status {
        try {
            amp->say(message);
            networkCounter.hitPhysicalOut(message.size());

            return Status::OK();
        } catch (const SocketException& e) {
            return {ErrorCodes::HostUnreachable, e.what()};
        }
    };

    auto legacySession = checked_pointer_cast<LegacySession>(session);
    return Ticket(
        this,
        stdx::make_unique<LegacyTicket>(std::move(legacySession), expiration, std::move(sinkCb)));
}
Ejemplo n.º 11
0
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#endif

#include <steam/steam_api.h>

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif


static const Ticket INVALID_TICKET = Ticket();

class SteamTicketRequests {
public:
    SteamTicketRequests();
    ~SteamTicketRequests();

    HAuthTicket startRequest(TicketRequestCallback callback);
    void stopRequest(HAuthTicket authTicket);
    void stopAll();

    STEAM_CALLBACK(SteamTicketRequests, onGetAuthSessionTicketResponse,
                   GetAuthSessionTicketResponse_t, _getAuthSessionTicketResponse);

private:
    struct PendingTicket {
Ejemplo n.º 12
0
Ticket TransportLayerMock::sinkMessage(const Session& session,
                                       const Message& message,
                                       Date_t expiration) {
    return Ticket(this, stdx::make_unique<MockTicket>());
}
Ejemplo n.º 13
0
Archivo: wad.cpp Proyecto: Swyter/wiiqt
Wad::Wad( QDir dir )
{
	ok = false;
	QFileInfoList tmds = dir.entryInfoList( QStringList() << "*.tmd" << "tmd.*", QDir::Files );
	if( tmds.isEmpty() )
	{
		Err( "TMD not found" );
		return;
	}
	tmdData = ReadFile( tmds.at( 0 ).absoluteFilePath() );
	if( tmdData.isEmpty() )
		return;
	QFileInfoList tiks = dir.entryInfoList( QStringList() << "*.tik" << "cetk", QDir::Files );
	if( tiks.isEmpty() )
	{
		Err( "Ticket not found" );
		return;
	}
	tikData = ReadFile( tiks.at( 0 ).absoluteFilePath() );
	if( tikData.isEmpty() )
		return;

	Tmd t( tmdData );
	Ticket ticket( tikData );

	//make sure to only add the tmd & ticket without all the cert mumbo jumbo
	tmdData = t.Data();
	tikData = ticket.Data();
	t = Tmd( tmdData );
	ticket = Ticket( tikData );

	quint16 cnt = t.Count();

	bool tmdChanged = false;
	for( quint16 i = 0; i < cnt; i++ )
	{
		QByteArray appD = ReadFile( dir.absoluteFilePath( t.Cid( i ) + ".app" ) );
		if( appD.isEmpty() )
		{
			Err( t.Cid( i ) + ".app not found" );
			return;
		}

		if( (quint32)appD.size() != t.Size( i ) )
		{
			t.SetSize( i, appD.size() );
			tmdChanged = true;
		}
		QByteArray realHash = GetSha1( appD );
		if( t.Hash( i ) != realHash )
		{
			t.SetHash( i, realHash );
			tmdChanged = true;
		}
		AesSetKey( ticket.DecryptedKey() );
		appD = PaddedByteArray( appD, 0x40 );
		QByteArray encData = AesEncrypt( t.Index( i ), appD );
		partsEnc << encData;
	}
	//if something in the tmd changed, fakesign it
	if( tmdChanged )
	{
		if( !t.FakeSign() )
		{
			Err( "Error signing the wad" );
			return;
		}
		else
		{
			tmdData = t.Data();
		}
	}
	QFileInfoList certs = dir.entryInfoList( QStringList() << "*.cert", QDir::Files );
	if( !certs.isEmpty() )
	{
		certData = ReadFile( certs.at( 0 ).absoluteFilePath() );
	}
	ok = true;
}