Search in sources :

Example 1 with MessageChannel

use of com.tvd12.calabash.server.core.message.MessageChannel in project calabash by youngmonkeys.

the class CalabashClientTest method test.

@SuppressWarnings("unchecked")
public void test() throws Exception {
    CalabaseClient client = CalabashClientFactory.builder().build().newClient();
    EntityMap<String, String> map = client.getMap("world", String.class, String.class);
    System.out.println("Map: " + map);
    map.set("Hello", "World");
    System.out.println("set ok");
    map.put("Foo", "Bar");
    System.out.println("put ok");
    map.putAll(EzyMapBuilder.mapBuilder().put("Who", "Are You?").build());
    System.out.println("Hello " + map.get("Hello"));
    System.out.println("Hello " + map.get(Sets.newHashSet("Hello", "Who")));
    IAtomicLong atomicLong = client.getAtomicLong("hello");
    System.out.println("AtomicLong.id = " + atomicLong);
    System.out.println("AtomicLong.value1 = " + atomicLong.incrementAndGet());
    System.out.println("AtomicLong.value2 = " + atomicLong.addAndGet(100));
    MessageChannel<String> messageChannel = client.getMessageChannel("hello", String.class);
    messageChannel.addSubscriber(message -> {
        System.out.println("received message: " + message);
    });
    System.out.println("message channel: " + messageChannel);
    Thread.sleep(500);
    messageChannel.publish("Don't do that");
    System.out.println("publish message ok");
}
Also used : CalabaseClient(com.tvd12.calabash.client.CalabaseClient) IAtomicLong(com.tvd12.calabash.core.IAtomicLong)

Example 2 with MessageChannel

use of com.tvd12.calabash.server.core.message.MessageChannel in project calabash by youngmonkeys.

the class MessageChannelRequestController method messageChannelPublish.

@Rpc(Commands.MESSAGE_CHANNEL_PUBLISH)
public void messageChannelPublish(MessageChannelPublishRequest request) {
    MessageChannel messageChannel = getMessageChannel(request.getChannelId());
    messageChannel.broadcast(request);
}
Also used : MessageChannel(com.tvd12.calabash.server.core.message.MessageChannel) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Example 3 with MessageChannel

use of com.tvd12.calabash.server.core.message.MessageChannel in project calabash by youngmonkeys.

the class MessageChannelRequestController method messageChannelPublish.

@Rpc(Commands.MESSGE_CHANNEL_SUBSCRIBE)
public boolean messageChannelPublish(MessageChannelSubscribeRequest request, RpcSession session) {
    MessageChannel messageChannel = getMessageChannel(request.getChannelId());
    messageChannel.addSubscriber(session);
    return Boolean.TRUE;
}
Also used : MessageChannel(com.tvd12.calabash.server.core.message.MessageChannel) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Example 4 with MessageChannel

use of com.tvd12.calabash.server.core.message.MessageChannel in project calabash by youngmonkeys.

the class SimpleMessageChannelManager method newChannel.

protected MessageChannel newChannel(String name) {
    synchronized (messageChannels) {
        MessageChannel channel = messageChannels.get(name);
        if (channel == null) {
            channel = factory.newChannel(name);
            messageChannels.put(name, channel);
        }
        return channel;
    }
}
Also used : MessageChannel(com.tvd12.calabash.server.core.message.MessageChannel)

Aggregations

MessageChannel (com.tvd12.calabash.server.core.message.MessageChannel)3 Rpc (com.tvd12.quick.rpc.server.annotation.Rpc)2 CalabaseClient (com.tvd12.calabash.client.CalabaseClient)1 IAtomicLong (com.tvd12.calabash.core.IAtomicLong)1