Package org.fotap.heysync

Source Code of org.fotap.heysync.HeysyncExample

package org.fotap.heysync;

import org.jetlang.fibers.ThreadFiber;

/**
* @author <a href="mailto:peter.royal@pobox.com">peter royal</a>
*/
public class HeysyncExample {

    public static void main(String... args) throws InterruptedException {
        // Create our fiber
        ThreadFiber fiber = new ThreadFiber();
        fiber.start();

        // Create protocol
        Protocol<Mouse> protocol = Protocol.create(Mouse.class);

        // Create our FieldMouse and subscribe him to the protocol
        FieldMouse fieldMouse = new FieldMouse();
        protocol.subscribe(fiber, fieldMouse);

        // Get the publisher for all registered Mice
        Mouse publisher = protocol.publisher();

        // Tell our mouse to eat cheese and provoke cats
        publisher.eatCheese("cheddar");
        publisher.provokeCats(2);
        publisher.provokeCatsWithTaunt(3, "I have your cheese");
        publisher.shoutWords("cats", "really", "stink");
        publisher.reciteNumbers(2, 4, 6, 8);

        fieldMouse.latch.await();
    }
}
TOP

Related Classes of org.fotap.heysync.HeysyncExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.