Пример #1
0
void CLogger::CallbackHandlerThread()
{
	for(; !this->TestDestroy(); this->Sleep(100))
	{
		wxMutexLocker steamLock(m_steamLock);

		if(!m_hPipe || m_hPipe == -1)
		{
			if(!InitSteam())
				continue;
		}

		static unsigned int i = 0;
		if(++i % 50 == 0)
		{
			// This dummy call will trigger the IPCFailure_t callback if Steam has been closed.
			if(m_pSteamUser)
				m_pSteamUser->BLoggedOn();
		}

		CallbackMsg_t callbackMsg;
		while(Steam_BGetCallback(m_hPipe, &callbackMsg))
		{
			switch(callbackMsg.m_iCallback)
			{
			case IPCFailure_t::k_iCallback:
				{
					IPCFailure_t* pIPCFailure = (IPCFailure_t*)callbackMsg.m_pubParam;
					OnIPCFailure(pIPCFailure);
					break;
				}
			case FriendChatMsg_t::k_iCallback:
				{
					FriendChatMsg_t* pFriendChatMsg = (FriendChatMsg_t*)callbackMsg.m_pubParam;
					OnFriendChatMsg(pFriendChatMsg);
					break;
				}
			case ChatRoomMsg_t::k_iCallback:
				{
					ChatRoomMsg_t* pChatRoomMsg = (ChatRoomMsg_t*)callbackMsg.m_pubParam;
					OnChatRoomMsg(pChatRoomMsg);
					break;
				}
			case ChatRoomDlgClose_t::k_iCallback:
				{
					ChatRoomDlgClose_t* pChatRoomDlgClose = (ChatRoomDlgClose_t*)callbackMsg.m_pubParam;
					OnChatRoomDlgClose(pChatRoomDlgClose);
					break;
				}
			}
			Steam_FreeLastCallback(m_hPipe);
		}
	}
}
Пример #2
0
static void runCallbackThread() 
{
	CallbackMsg_t msg;
	while( sppClient.isRunning() && Steam_BGetCallback( sppClient.getSteamPipe(), &msg) ) // BGetCallback is (B)locking
	{
		/* The '0' callback has no meaning, and I'm replacing it to give it a new one.
		 * Any script that registers it, will have it called every tick. Like an infinite loop.
		 * This serves the purpose of keeping alive scripts which depend on their state, and also
		 * provides a way of creating non-blocking infinite loops.
		 * 
		 * If a script wants to commit sudoku, all it has to do is unregister all of its callbacks.
		 */
		if( msg.m_iCallback != 0 ) {
			spp::fireCallbacks( msg.m_iCallback, msg.m_pubParam );
		}
		
		Steam_FreeLastCallback(sppClient.getSteamPipe());
	}
}
Пример #3
0
int main()
{
	bool sessionClosed = true;
	bool fuckedOff = false;

	CSteamID stanId( (uint64)76561197996282699LL );

	ISteamClient007 *steamClient;
	if ( !Sys_LoadInterface( "steamclient", STEAMCLIENT_INTERFACE_VERSION_007, NULL, (void**)&steamClient ) )
	{
		getchar();
		return 0;
	}

	HSteamPipe pipe = steamClient->CreateSteamPipe();
	HSteamUser user = steamClient->ConnectToGlobalUser( pipe );

	ISteamFriends001 *steamFriends = (ISteamFriends001 *)steamClient->GetISteamFriends( user, pipe, STEAMFRIENDS_INTERFACE_VERSION_001 );

	CallbackMsg_t callBack;
	HSteamCall steamCall;

	while ( true )
	{
		if ( Steam_BGetCallback( pipe, &callBack, &steamCall ) )
		{
			if ( callBack.m_iCallback == FriendEndChatSession_t::k_iCallback )
			{
				FriendEndChatSession_t *chatEnd = (FriendEndChatSession_t *)callBack.m_pubParam;

				if ( chatEnd->m_SteamID == stanId )
				{
					sessionClosed = true;
					fuckedOff = false;
				}
			}
			if ( callBack.m_iCallback == FriendChatMsg_t::k_iCallback )
			{
				FriendChatMsg_t *chatMsg = (FriendChatMsg_t *)callBack.m_pubParam;

				if (chatMsg->m_ulSender != stanId.ConvertToUint64())
				{
					Steam_FreeLastCallback( pipe );

					continue;
				}

				EFriendMsgType msgType;
				steamFriends->GetChatMessage( chatMsg->m_ulSender, chatMsg->m_iChatID, NULL, 0, &msgType );

				if ( msgType == k_EFriendMsgTypeTyping )
				{
					if ( sessionClosed )
					{
						steamFriends->SendMsgToFriend( stanId, k_EFriendMsgTypeChat, "what teh f**k do you want" );
						sessionClosed = false;
					}
				}

				if ( msgType == k_EFriendMsgTypeChat )
				{
					if ( !fuckedOff )
					{
						steamFriends->SendMsgToFriend( stanId, k_EFriendMsgTypeChat, "no." );
						fuckedOff = true;
					}
				}
			}

			Steam_FreeLastCallback( pipe );

		}
		Sleep(10);
	}

	return 0;
}