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)); }
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)); }
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))); }
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))); }
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; } }
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); }
// 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; } }
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))); }
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 }
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))); }
#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 {
Ticket TransportLayerMock::sinkMessage(const Session& session, const Message& message, Date_t expiration) { return Ticket(this, stdx::make_unique<MockTicket>()); }
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; }