Package Index

Junction is a library for creating device-spanning, cross-platform applications. Junction provides an abstraction layer so that an application can easily communicate across devices. To get started, see the following classes:

The following is a basic Junction application. The code joins a freshly generated Junction session, sends a message, and prints the message to screen upon receiving it:

package edu.stanford.junction.demo;

import java.net.URI;

import org.json.JSONException;
import org.json.JSONObject;

import edu.stanford.junction.JunctionException;
import edu.stanford.junction.api.activity.JunctionActor;
import edu.stanford.junction.api.messaging.MessageHeader;
import edu.stanford.junction.provider.xmpp.XMPPSwitchboardConfig;

public class JunctionDemo {
  public static void main(String... args) {
    SwitchboardConfig config = new XMPPSwitchboardConfig("sb.openjunction.org");
    JunctionMaker junctionMaker = JunctionMaker.getInstance(config);
    JunctionActor actor = new MyActor();
    URI uri = junctionMaker.generateSessionUri();
    try {
      junctionMaker.newJunction(uri, actor);
    } catch (JunctionException e) {
      e.printStackTrace();
    }
    // Junction runs off of this thread.
    synchronized(actor) {
    try {
      actor.wait();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
	
static class MyActor extends JunctionActor {
  public void onMessageReceived(MessageHeader header, JSONObject message) {
    System.out.println("Got " + message);
    // We're done here, let the main thread exit.
    synchronized (this) {
      this.notify();
    }
  }

  public void onActivityJoin() {
    JSONObject message = null;
    try {
      message = new JSONObject("{\"text\":\"hello world!\"}");
    } catch (JSONException e) {}
      this.sendMessageToSession(message);
    };
  };
}

edu.stanford.junction
edu.stanford.junction.addon
edu.stanford.junction.api.activity
edu.stanford.junction.api.messaging
edu.stanford.junction.api.messaging.target
edu.stanford.junction.director
edu.stanford.junction.extra
edu.stanford.junction.props2
edu.stanford.junction.props2.sample
edu.stanford.junction.provider
edu.stanford.junction.provider.irc
edu.stanford.junction.provider.jvm
edu.stanford.junction.provider.jx
edu.stanford.junction.provider.jx.json
edu.stanford.junction.provider.xmpp
edu.stanford.junction.sample.helloworld
edu.stanford.junction.sample.sql
edu.stanford.junction.simulator
edu.stanford.junction.test.multiconnect