当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionSource类代码示例

本文整理汇总了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.");
    }
  }
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:31,代码来源:ServerMain.java

示例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.");
    }
  }
}
 
开发者ID:Pandarati,项目名称:CodeU-Summer-2017,代码行数:29,代码来源:ServerMain.java

示例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.");
    }
  }
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:29,代码来源:ServerMain.java

示例4: Controller

import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public Controller(ConnectionSource source) {
  this.source = source;
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:4,代码来源:Controller.java

示例5: Context

import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public Context(ConnectionSource source) {
  this.view = new View(source);
  this.controller = new Controller(source);
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:5,代码来源:Context.java

示例6: View

import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public View(ConnectionSource source) {
  this.source = source;
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:4,代码来源:View.java

示例7: RemoteRelay

import codeu.chat.util.connections.ConnectionSource; //导入依赖的package包/类
public RemoteRelay(ConnectionSource source) {
  this.source = source;
}
 
开发者ID:EVelez79,项目名称:CodeU-ProjectGroup6,代码行数:4,代码来源:RemoteRelay.java

示例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.");
  }
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:34,代码来源:ClientMain.java


注:本文中的codeu.chat.util.connections.ConnectionSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。