Notice APP Network - person-in-hangang/HanRiver GitHub Wiki

Connect with Server - Socket Settings

This is a connection operation for socket communication with the server. Through this connection, Notice app can receive photo of person on the bridge, person information, trajectory and location information.

Step 1. Add the following permission to the manifest.

...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
...

Step 2. Enter the IP address and PORT number of the server.

In RealtimeFragment.java

line 70

private int port = PORT_NUMBER;

line 189, 280, 371, 448 (The code below corresponds to line 189.)

void connect(){
        mHandler = new Handler(Looper.getMainLooper());
        Log.w("connect","연결 하는중");
        // 받아오는거
        t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                // 서버 접속
                String newip = "IP_ADDRESS";
                try {
                    socket = new Socket(newip, port);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }