本文整理汇总了Java中codeu.chat.util.connections.ConnectionSource类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionSource类的具体用法?Java ConnectionSource怎么用?Java ConnectionSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionSource类属于codeu.chat.util.connections包,在下文中一共展示了ConnectionSource类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runServer
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
private static void runServer(Uuid id,
Secret secret,
ConnectionSource serverSource,
ConnectionSource relaySource) {
final Relay relay = relaySource == null ?
new NoOpRelay() :
new RemoteRelay(relaySource);
final Server server = new Server(id, secret, relay);
LOG.info("Created server.");
server.restoreServer(); //Immediately added to timeline
server.saveServer(); //Set to execute every 30 seconds from being called
while (true) {
try {
LOG.info("Established connection...");
final Connection connection = serverSource.connect();
LOG.info("Connection established.");
server.handleConnection(connection);
} catch (IOException ex) {
LOG.error(ex, "Failed to establish connection.");
}
}
}
示例2: runServer
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
private static void runServer(Uuid id,
Secret secret,
ConnectionSource serverSource,
ConnectionSource relaySource) throws IOException {
final Relay relay = relaySource == null ?
new NoOpRelay() :
new RemoteRelay(relaySource);
final Server server = new Server(id, secret, relay);
LOG.info("Created server.");
while (true) {
try {
LOG.info("Established connection...");
final Connection connection = serverSource.connect();
LOG.info("Connection established.");
server.handleConnection(connection);
} catch (IOException ex) {
LOG.error(ex, "Failed to establish connection.");
}
}
}
示例3: runServer
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
private static void runServer(Uuid id,
byte[] secret,
ConnectionSource serverSource,
ConnectionSource relaySource) {
final Relay relay = relaySource == null ?
new NoOpRelay() :
new RemoteRelay(relaySource);
final Server server = new Server(id, secret, relay);
LOG.info("Created server.");
while (true) {
try {
LOG.info("Established connection...");
final Connection connection = serverSource.connect();
LOG.info("Connection established.");
server.handleConnection(connection);
} catch (IOException ex) {
LOG.error(ex, "Failed to establish connection.");
}
}
}
示例4: Controller
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public Controller(ConnectionSource source) {
this.source = source;
}
示例5: Context
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public Context(ConnectionSource source) {
this.view = new View(source);
this.controller = new Controller(source);
}
示例6: View
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public View(ConnectionSource source) {
this.source = source;
}
示例7: RemoteRelay
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public RemoteRelay(ConnectionSource source) {
this.source = source;
}
示例8: main
import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public static void main(String [] args) {
try {
Logger.enableFileOutput("chat_client_log.log");
} catch (IOException ex) {
LOG.error(ex, "Failed to set logger to write to file");
}
LOG.info("============================= START OF LOG =============================");
LOG.info("Starting chat client...");
final RemoteAddress address = RemoteAddress.parse(args[0]);
final ConnectionSource source = new ClientConnectionSource(address.host, address.port);
final Controller controller = new Controller(source);
final View view = new View(source);
LOG.info("Creating client...");
final Chat chat = new Chat(controller, view);
LOG.info("Created client");
final Scanner input = new Scanner(System.in);
while (chat.handleCommand(input)) {
// everything is done in "run"
}
input.close();
LOG.info("chat client has exited.");
}