This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var app = express(); // 이번 예제에서는 express를 사용합니다. | |
var socketio = require('socket.io'); | |
var server = app.listen(3001,()=>{ | |
console.log('Listening at port number 3001') //포트는 원하시는 번호로.. | |
}) | |
//return socket.io server. | |
var io = socketio.listen(server) // 이 과정을 통해 우리의 express 서버를 socket io 서버로 업그레이드를 시켜줍니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Socket-io client를 build.gradle 파일에 추가해 준다 | |
dependencies{ | |
implementation('io.socket:socket.io-client:1.0.0') { | |
exclude group: 'org.json', module: 'json' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.junga.realtime | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.util.Log | |
import io.socket.client.IO | |
import io.socket.client.Socket | |
import io.socket.emitter.Emitter | |
import kotlinx.android.synthetic.main.activity_main.* | |
import org.json.JSONException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
android { | |
compileSdkVersion 29 | |
buildToolsVersion "29.0.1" | |
defaultConfig { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Joyce Hong | |
* @email [email protected] | |
* @create date 2019-09-02 20:51:10 | |
* @modify date 2019-09-02 20:51:10 | |
* @desc socket.io server ! | |
*/ | |
const express = require('express'); | |
const bodyParser = require('body-parser'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.junga.socketio_android | |
import android.os.Bundle | |
import android.util.Log | |
import android.view.View | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.recyclerview.widget.LinearLayoutManager | |
import com.google.gson.Gson | |
import com.junga.socketio_android.model.MessageType | |
import io.socket.client.IO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun ViewPager2.setCurrentItemWithDuration( | |
item: Int, | |
duration: Long, | |
interpolator: TimeInterpolator = AccelerateDecelerateInterpolator(), | |
pagePxWidth: Int = width // Default value taken from getWidth() from ViewPager2 view | |
) { | |
val pxToDrag: Int = pagePxWidth * (item - currentItem) | |
val animator = ValueAnimator.ofInt(0, pxToDrag) | |
var previousValue = 0 | |
animator.addUpdateListener { valueAnimator -> |