當前位置: 首頁>>代碼示例>>Java>>正文


Java Chat類代碼示例

本文整理匯總了Java中codeu.chat.client.commandline.Chat的典型用法代碼示例。如果您正苦於以下問題:Java Chat類的具體用法?Java Chat怎麽用?Java Chat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Chat類屬於codeu.chat.client.commandline包,在下文中一共展示了Chat類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import codeu.chat.client.commandline.Chat; //導入依賴的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.client.commandline.Chat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。