//---------------------------------------------------------------------------
void TMinosChatForm::chatServerCallback( bool err, MinosRPCObj *mro, const std::string &from )
{
   trace( "chat callback from " + from + ( err ? ":Error" : ":Normal" ) );

   if ( !err )
   {
      boost::shared_ptr<RPCParam> psName;
      boost::shared_ptr<RPCParam>psValue;
      RPCArgs *args = mro->getCallArgs();
      if ( args->getStructArgMember( 0, "Name", psName ) && args->getStructArgMember( 0, "Value", psValue ) )
      {
         std::string Name;
         std::string Value;

         if ( psName->getString( Name ) && psValue->getString( Value ) )
         {
            boost::shared_ptr<RPCParam>st(new RPCParamStruct);

            if ( Name == "SendChatMessage" )
            {
               CsGuard g;
               // add to chat window
               std:: string mess = from + " : " + Value;
               addChat( mess );
            }
            st->addMember( true, "ChatResult" );
            mro->clearCallArgs();
            mro->getCallArgs() ->addParam( st );
            mro->queueResponse( from );
         }
      }
   }
}
	void PrivateChatApi::on(MessageManagerListener::ChatCreated, const PrivateChatPtr& aChat, bool aReceivedMessage) noexcept {
		addChat(aChat);
		if (!subscriptionActive("private_chat_created")) {
			return;
		}

		send("private_chat_created", serializeChat(aChat));
	}
void TMinosChatForm::notifyCallback( bool err, MinosRPCObj *mro, const std::string &from )
{
   logMessage( "Notify callback from " + from + ( err ? ":Error" : ":Normal" ) );
   AnalysePubSubNotify an( err, mro );

   if ( an.getOK() )
   {
      if ( an.getCategory() == "Station" )
      {
         CsGuard g;
         std::string key = an.getKey();
         std::string value = an.getValue();
         PublishState state = an.getState();
         logMessage( std::string(stateIndicator[state]) + " " + key + " " + value );
         std::vector<Server>::iterator stat;
         for ( stat = serverList.begin(); stat != serverList.end(); stat++ )
         {
            if ((*stat).name == key)
            {
               if ((*stat).state != state)
               {
                  (*stat).state = state;
                  std:: string mess = key + " changed state to " + std::string(stateList[state]);
                  addChat( mess );
                  syncstat = true;
               }
               break;
            }
         }

         if ( stat == serverList.end() )
         {
            // We have received notification from a previously unknown station - so report on it
            Server s;
            s.name = key;
            s.ip = value;
            s.state = state;
            serverList.push_back( s );
            std:: string mess = key + " changed state to " + std::string(stateList[state]);
            addChat( mess );
            syncstat = true;
         }
      }
   }
}
Beispiel #4
0
void drawFrame( spades::client::IRenderer& renderer )
{
	if( !designFont ) {
		renderer.Init();
		designFont = new spades::client::Quake3Font(&renderer, renderer.RegisterImage("Gfx/Fonts/UnsteadyOversteer.tga"), (const int *)UnsteadyOversteerMap, 30, 18);
		textFont = new spades::client::Quake3Font(&renderer, renderer.RegisterImage("Gfx/Fonts/UbuntuCondensed.tga"), (const int*)UbuntuCondensedMap, 24, 4); 
		bigTextFont = new spades::client::Quake3Font(&renderer, renderer.RegisterImage("Gfx/Fonts/UbuntuCondensedBig.tga"), (const int*)UbuntuCondensedBigMap, 48, 8);
		orbitronFont = new spades::client::Quake3Font(&renderer, renderer.RegisterImage("Gfx/Fonts/Orbitron.tga"), (const int*)OrbitronMap, 30, 18);
		whiteImage = renderer.RegisterImage("Gfx/White.tga");
		chatWindow = new spades::client::ChatWindow( NULL, &renderer, textFont, false );
		killfeedWindow = new spades::client::ChatWindow( NULL, &renderer, textFont, true );
		ot = SDL_GetTicks();
		srand( ot );
	}
	spades::client::SceneDefinition sceneDef;
	sceneDef.viewOrigin = spades::MakeVector3(0, 0, 0);
	sceneDef.viewAxis[0] = spades::MakeVector3(1, 0, 0);
	sceneDef.viewAxis[1] = spades::MakeVector3(0, 0, -1);
	sceneDef.viewAxis[2] = spades::MakeVector3(0, 0, 1);	
	sceneDef.fovY = (float)cg_fov * static_cast<float>(M_PI) /180.f;
	sceneDef.fovX = atanf(tanf(sceneDef.fovY * .5f) * renderer.ScreenWidth() / renderer.ScreenHeight()) * 2.f;		
	sceneDef.zNear = 0.05f;
	sceneDef.zFar = 130.f;
	sceneDef.skipWorld = true;	
	renderer.SetFogColor(spades::MakeVector3(0,0,0));

	renderer.StartScene(sceneDef);
	renderer.EndScene();

	spades::Vector2 scrSize = { renderer.ScreenWidth(), renderer.ScreenHeight() };
	renderer.SetColor( spades::MakeVector4( 0.5f, 0.5f, 0.5f, 1 ) );
	renderer.DrawImage( whiteImage, spades::AABB2(0, 0, scrSize.x, scrSize.y) );
	

	Uint32 dt = SDL_GetTicks() - ot;
	float fdt = (float)dt / 1000.f;
	chatWindow->Update( fdt );
	killfeedWindow->Update( fdt );
	ot += dt;
	
	if( !nextChat || ot >= nextChat ) {
		nextChat = ot + 1000 + (rand() % 2000);
		addChat();
	}

	if( !nextKill || ot >= nextKill ) {
		nextKill = ot + 200 + (rand() % 1000);
		addKill();
	}

	chatWindow->Draw();
	killfeedWindow->Draw();

	renderer.FrameDone();
	renderer.Flip();
}
ChatWidget *ChatWidgetContainerHandlerMapper::createHandledChatWidget(Chat chat, OpenChatActivation activation)
{
    auto chatWidgetContainerHandler = bestContainerHandler(chat);
    if (!chatWidgetContainerHandler)
        return nullptr;

    map(chatWidgetContainerHandler, chat);

    auto chatWidget = chatWidgetContainerHandler->addChat(chat, activation);
    if (m_chatWidgetRepository)
        m_chatWidgetRepository.data()->addChatWidget(chatWidget);

    return chatWidget;
}
void MessageManager::onPrivateMessage(const ChatMessagePtr& aMessage) {
	bool myPM = aMessage->getReplyTo()->getUser() == ClientManager::getInstance()->getMe();
	const UserPtr& user = myPM ? aMessage->getTo()->getUser() : aMessage->getReplyTo()->getUser();
	size_t wndCnt;
	{
		WLock l(cs);
		wndCnt = chats.size();
		auto i = chats.find(user);
		if (i != chats.end()) {
			i->second->handleMessage(aMessage); //We should have a listener in the frame
			return;
		}
	}

	auto c = aMessage->getFrom()->getClient();
	if (wndCnt > 200 || (!myPM && isIgnoredOrFiltered(aMessage, c.get(), true))) {
		DisconnectCCPM(user);
		return;
	}

	const auto& identity = aMessage->getReplyTo()->getIdentity();
	if ((identity.isBot() && !SETTING(POPUP_BOT_PMS)) || (identity.isHub() && !SETTING(POPUP_HUB_PMS))) {
		c->Message(STRING(PRIVATE_MESSAGE_FROM) + " " + identity.getNick() + ": " + aMessage->format());
		return;
	}

	auto chat = addChat(HintedUser(user, aMessage->getReplyTo()->getClient()->getHubUrl()), true);
	chat->handleMessage(aMessage);

	if (AirUtil::getAway() && (!SETTING(NO_AWAYMSG_TO_BOTS) || !user->isSet(User::BOT))) {
		ParamMap params;
		aMessage->getFrom()->getIdentity().getParams(params, "user", false);

		string error;
		chat->sendMessage(AirUtil::getAwayMessage(c->get(HubSettings::AwayMsg), params), error, false);
	}
}