Beispiel #1
0
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

try:
    from pubsub import Publisher
    WxPublisher = Publisher()
except ImportError:
    from pubsub import pub
    WxPublisher = pub.getDefaultPublisher()


class Publisher(object):

    def __init__(self):
        self._listeners = {}

    def publish(self, topic, data):
        self._sendMessage(topic, data)

    def subscribe(self, listener, topic, key=None):
        """Start to listen to messages with the specified ``topic``.

        The ``topic`` can be either a message class or a dot separated topic
        string, and the ``listener`` must be a callable accepting a message
Beispiel #2
0
 def __init__(self):
     self._publisher = pub.getDefaultPublisher()
     self._publisher.setListenerExcHandler(ListenerExceptionHandler())
Beispiel #3
0
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

from robotide.utils import PY3
if PY3:
    from robotide.utils import basestring, unicode

try:
    from pubsub import Publisher
    WxPublisher = Publisher()
except ImportError:
    from pubsub import pub
    WxPublisher = pub.getDefaultPublisher()


class Publisher(object):

    def __init__(self):
        self._listeners = {}

    def publish(self, topic, data):
        self._sendMessage(topic, data)

    def subscribe(self, listener, topic, key=None):
        """Start to listen to messages with the specified ``topic``.

        The ``topic`` can be either a message class or a dot separated topic
        string, and the ``listener`` must be a callable accepting a message