Git Product home page Git Product logo

gomochat's Introduction

gomochat

gomobile を使ってチャットクライアントを作ってみる

ビルド方法

事前準備

  • go コマンドが使える状態になっていること
  • gomobile コマンドが使える状態になっていること
  • Android Studio 3.0.1 がインストールされていること

コマンドラインで apk をビルドする

  • トップディレクトリににて make を実行します。
    • gomobile bind による AAR 生成、その後 apk 生成までやります。

Android Studio で apk をビルドする

  • make bind コマンドで gomochat.aar を生成しておきます。
  • android ディレクトリを Android Studio に読み込ませます。
  • ビルドして APK を生成し、実機に食わせるなりエミュレータに食わせるなりします。

アプリの説明

簡易なチャットアプリです。

サーバを立てる

  • gomochat/cmd/server 以下に、サーバのソースコードが格納されています。
    • gorilla/websocket/example 以下の chat と同じものです。
    • 当該ディレクトリに行き、go build でサーバ実行バイナリが生成されます。

クライアント (cli) を接続する

  • gomochat/cmd/gomochat 以下に、延々とメッセージ受信送信を繰り返すだけのアプリが格納されています。
    • 当該ディレクトリに行き、go build でクライアントの実行バイナリが生成されます。
    • あらかじめサーバを起動しておき、本クライアントを実行します。WebSocket が接続され、メッセージの送受信が始まります。
    • メッセージは、接続中のクライアント全ての転送されます。

クライアント (Android アプリ) を接続する

  • gomochat/android を Android Studio で読み込みます。
  • MainActivity.kt 内に接続先のアドレスがハードコーディングされているので、
    上記で立てたサーバの IP アドレスに修正し、ビルドします。
  • 生成した APK を、実機、ないしエミュレータにインストールします。
  • アプリは起動すると自動的にサーバに接続しようとします。
  • 名前、メッセージを入力する欄があるので、入力し、SEND ボタンを押すとメッセージを送信します。
    • メッセージは、接続中のクライアント全ての転送されます。

LICENSE

  • gomochat/cmd/server のソースコードは gorilla/websocket のライセンスに従います。
  • その他は MIT です。

gomochat's People

Contributors

pankona avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

go-mobile

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.