int Ardb::Publish(Context& ctx, RedisCommandFrame& cmd) { const std::string& channel = cmd.GetArguments()[0]; const std::string& message = cmd.GetArguments()[1]; int count = 0; count += PublishMessage(ctx, channel, message); fill_int_reply(ctx.reply, count); return 0; }
//---------------------------------------------- // menu item executed //---------------------------------------------- void TLMenu::TMenuController::OnMenuItemExecuted(TRefRef MenuCommand, TBinaryTree& MenuData) { TLMessaging::TMessage Message("Execute"); // write the command into the message Message.ExportData("Command", MenuCommand ); TPtr<TBinaryTree> pChild = Message.AddChild("Menudata"); if(pChild) pChild->ReferenceDataTree(MenuData); PublishMessage( Message ); }
/*********************************************************** callback function called when a message is received from IceStorm ***********************************************************/ void ChatReceiverServant::Message(const std::string& Sender, const std::string& Text, const Ice::Current&) { if(Sender == "info") { if(Text.substr(0, 7) == "#joined") { LbaNet::UserJoinedEventPtr ev = new LbaNet::UserJoinedEvent(); ev->timestamp = IceUtil::Time::now().toMilliSeconds(); ev->name = Text.substr(8); PublishOther(ev); return; } if(Text.substr(0, 5) == "#left") { LbaNet::UserLeftEventPtr ev = new LbaNet::UserLeftEvent(); ev->timestamp = IceUtil::Time::now().toMilliSeconds(); ev->name = Text.substr(6); PublishOther(ev); return; } if(Text.substr(0, 7) == "#status") { LbaNet::UserStatusEventPtr ev = new LbaNet::UserStatusEvent(); ev->timestamp = IceUtil::Time::now().toMilliSeconds(); std::string tmptxt = Text.substr(8); ev->name = tmptxt.substr(0, tmptxt.find(" ")); tmptxt = tmptxt.substr(tmptxt.find(" ")+1); ev->status = tmptxt.substr(0, tmptxt.find(" ")); tmptxt = tmptxt.substr(tmptxt.find(" ")+1); ev->color = tmptxt.substr(0, tmptxt.find(" ")); //todo //tmptxt = tmptxt.substr(tmptxt.find(" ")+1); //ev->location = tmptxt; PublishStatus(ev); return; } } LbaNet::MessageEventPtr ev = new LbaNet::MessageEvent(); ev->timestamp = IceUtil::Time::now().toMilliSeconds(); ev->name = Sender; ev->message = Text; PublishMessage(ev); }
//------------------------------------------------- // process a click and detect clicks on/off our render node. return SyncWait if we didnt process it and want to process again //------------------------------------------------- SyncBool TLGui::TWidgetThumbStick::ProcessClick(TClick& Click,TLRender::TScreen& Screen,TLRender::TRenderTarget& RenderTarget,TLRender::TRenderNode& RenderNode,const TLMaths::TShapeSphere2D& BoundsDatum,const TLMaths::TShape* pClickDatum) { Bool bClickAction = TLGui::g_pWidgetManager->IsClickActionRef(Click.GetActionRef()); Bool bMoveAction = TLGui::g_pWidgetManager->IsMoveActionRef(Click.GetActionRef()); Bool bCurrentAction = FALSE; Bool bActionPair = FALSE; if(m_ActionBeingProcessedRef.IsValid()) { bCurrentAction = (Click.GetActionRef() == m_ActionBeingProcessedRef); bActionPair = TLGui::g_pWidgetManager->IsActionPair(m_ActionBeingProcessedRef, Click.GetActionRef()); } Bool bTestIntersection = FALSE; if(m_ActionBeingProcessedRef.IsValid()) { if(bClickAction && bCurrentAction) { if(Click.GetActionType() == TLGui_WidgetActionType_Up ) { OnClickEnd( Click ); m_ActionBeingProcessedRef.SetInvalid(); return SyncTrue; } } else if(bMoveAction && bActionPair) { bTestIntersection = TRUE; } } else if(bClickAction) { if(Click.GetActionType() == TLGui_WidgetActionType_Up ) { if(bCurrentAction) { OnClickEnd( Click ); m_ActionBeingProcessedRef.SetInvalid(); return SyncTrue; } } else { // No 'click' action in progress yet. Test intersection bTestIntersection = TRUE; } } if(!bTestIntersection) return SyncFalse; // see if ray intersects our object, and creates a valid ray SyncBool Intersection = IsIntersecting(Screen, RenderTarget, RenderNode, BoundsDatum, pClickDatum, Click ); if ( Intersection == SyncTrue ) { if(bClickAction) m_ActionBeingProcessedRef = Click.GetActionRef(); } else if ( Intersection == SyncFalse ) { OnClickEnd( Click ); if(bClickAction) m_ActionBeingProcessedRef.SetInvalid(); return SyncFalse; } else if ( Intersection == SyncWait ) { return SyncWait; } /* SyncBool Result = TWidget::ProcessClick(Click, Screen, RenderTarget, RenderNode); if(Result != SyncTrue) return Result; */ // Custom OnClick effectively... // get the 2d circle bounds as the thumbstick // if not valid, wait till next frame (off-screen?) const TLMaths::TShapeSphere2D& BoundsSphere = RenderNode.GetWorldBoundsSphere2D(); if ( !BoundsSphere.IsValid() ) return SyncWait; // get vector from center of the sphere to the click point float2 ClickVector = Click.GetWorldRay().GetStart().xy() - BoundsSphere.GetCenter().xy(); // normalise vector to 0..1 in the sphere ClickVector /= BoundsSphere.GetSphere().GetRadius(); // get length to work out normalised vector and if we're in the deadzone float VectorLen = ClickVector.Length(); // in the dead zone, return TRUE (processed click) but don't send out a message // this "ignores" the click if ( VectorLen <= m_DeadZone ) return SyncTrue; // send out thumb stick message TRef ActionOutRef = m_ActionOutDown; if ( ActionOutRef.IsValid() ) { #ifdef _DEBUG TTempString Debug_String("WidgetThumbstick ("); m_RenderNodeRef.GetString( Debug_String ); Debug_String.Append(") sending thumbstick message: "); ActionOutRef.GetString( Debug_String ); Debug_String.Appendf(": %.2f, %.2f", ClickVector.x, ClickVector.y ); TLDebug_Print( Debug_String ); #endif // make up fake input message TLMessaging::TMessage Message(TRef_Static(A,c,t,i,o)); Message.Write( ActionOutRef ); Message.ExportData("RawData", ClickVector ); // send message PublishMessage( Message ); } return SyncTrue; }
//---------------------------------------------- // highlighted menu item //---------------------------------------------- void TLMenu::TMenuController::OnMenuItemHighlighted() { TLMessaging::TMessage Message("Highlight"); PublishMessage( Message ); }
//---------------------------------------------- // closed all menus //---------------------------------------------- void TLMenu::TMenuController::OnMenuCloseAll() { TLMessaging::TMessage Message("CloseAll"); PublishMessage( Message ); }
//---------------------------------------------- // moved onto new menu //---------------------------------------------- void TLMenu::TMenuController::OnMenuOpen() { TLMessaging::TMessage Message("Open"); PublishMessage( Message ); }