โ ์ฝ๋ ๋ค์ด๋ก๋ / Code Download
https://github.com/gideonslife01/flm-js-nodejs
๐ ์ด ์ฑ์ ๋ก๊ทธ์ธ๊ณผ ์์ผ๋ฉ์ธ์ง ๋ฐ์ก๊ธฐ๋ฅ์ด ์์ต๋๋ค.(์น,๋ชจ๋ฐ์ผ ์ฑ[๋ฆฌ์กํธ๋ค์ดํฐ๋ธ])
This app has login and socket message sending functions. (Web, mobile app [React Native])
๐ SockeetMessage๋ ๋ฆฌ์กํธ๋ค์ดํฐ๋ธ์
๋๋ค. ํ๋ก์ ํธ๋ฅผ ์๋กญ๊ฒ ์์ฑํด์ ์ฌ์ฉํ์ธ์
SocketMessage is for React Native. Please create a new project to use it.
๐1.๋๋ ํ ๋ฆฌ/Directory
1)nodejs+socketMessage/ReactNativeApp/ : ๋ฆฌ์กํธ๋ค์ดํฐ๋ธ / ReactNative
— ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ
android index.js ios package.json src
— src ๋๋ ํ ๋ฆฌ
src : ์ฑ ์์ค์ฝ๋/App souce code
- files : MainScreen.js,LoginScreen.js,index.js
- MainScreen.js,LoginScreen.js,index.js๋ ๊ธฐ์กด ๋ก๊ทธ์ธ ํ์ผ๊ณผ ๋์ผํฉ๋๋ค.
MainScreen.js, LoginScreen.js, and index.js are the same as the existing login files.
- SocketMessage.js๋ ์์ผ๋ฉ์ธ์ง ์์ ๋ฐ ๋ฐ์ก ํด๋ผ์ด์ธํธ์
๋๋ค.
SocketMessage.js is a socket message receiving and sending client.
— ios ๋๋ ํ ๋ฆฌ / ios direactory
ios : ios์ค์ ํ์ผ๋ก httpํ์ฉ์ค์ ํ์ผ์ด ์์ต๋๋ค. / There is an iOS configuration file for allowing HTTP connections.
- info.plist
— android ๋๋ ํ ๋ฆฌ / android directory
android : Android SDk์์น๊ฐ ์์ต๋๋ค. / There is an Android SDK location.
- local.properties
2)nodejs+socketMessage/login+socketmessage : Nodejs
— ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ / files and directory
node_modules package.json server.js
package-lock.json public
— public : ejs ํ์ผ / ejs files
login.ejs SocketMessage.ejs
— server.js : ์๋ฒ ์คํํ์ผ์ ๋๋ค. / This is the server executable file.
๐2.๋ฆฌ์กํธ๋ค์ดํฐ๋ธ์ค์น / ReactNative Install
1)ํ๋ก์ ํธ ์์ฑ : Project creation
https://reactnative.dev/docs/getting-started-without-a-framework
– ๋ค์ ๋ช
๋ น์ด๋ก ํ๋ก์ ํธ๋ฅผ ์์ฑํฉ๋๋ค. / Create a project with the following command.
npx @react-native-community/cli@latest init Your Project name
— ๋ชจ๋์ค์น / modules install
โ๏ธpackage.jsonํ์ผ์์ ์๋ ๋ถ๋ถ์ ๋ชจ๋์ ๋ณผ ์ ์์ต๋๋ค.
You can see the modules in the following section in the package.json file.
โ๏ธnpm install @react-native-async-storage/async-storage ์ด๋ ๊ฒ ์ค์น ํ์๋ฉด ๋ฉ๋๋ค.
You can install it like this: npm install @react-native-async-storage/async-storage.
"dependencies": {
"@react-native-async-storage/async-storage": "^2.1.2",
"@react-navigation/native": "^7.1.8",
"@react-navigation/stack": "^7.3.1",
"react": "19.0.0",
"react-native": "0.79.2",
"react-native-gesture-handler": "^2.25.0",
"react-native-safe-area-context": "^5.4.0",
"react-native-screens": "^4.10.0",
"socket.io-client": "^4.8.1"
},
npm install @react-native-async-storage/async-storage@latest
npm install @react-navigation/native@latest
npm install @react-navigation/stack@latest
npm install react-native-gesture-handler@latest
npm install react-native-safe-area-context@latest
npm install react-native-screens@latest
npm install socket.io-client@latest
2)์๋๋ก์ด๋์ค์ / android settings
–๐ ์ด ๋ถ๋ถ์ ์ค๋ฅ ๋ฐ์์์๋ง ์ ์ฉํฉ๋๋ค.
This part applies only when an error occurs.
— sdk location์ค์ / sdk location settings
project/android/locals.propertiesํ์ผ์ด ์์ผ๋ฉด ์์ฑ
— locals.propertiesํ์ผ์ ์๋๋ก์ด๋ sdk์์น๋ฅผ ์
๋ ฅ / Enter the Android SDK location in the locals.properties file
โปsdk์์น๋ ์๋๋ก์ด๋ ์คํ๋์ค ๋ฉ๋ด์ settings->Language & Frameworks->Android SDK->Android SDK Location์์ ํ์ธ ๊ฐ๋ฅ
You can check the SDK location in the Android Studio menu: settings->Language & Frameworks->Android SDK->Android SDK Location
sdk.dir=/Users/gimdaegyeong/Library/Android/sdk
3)IOS ์ค์ / IOS Settings
— ๋ชจ๋์ ์ค์นํ๋ฉด ๋ฐ๋์ ios๋๋ ํ ๋ฆฌ์ ๋ค์ด๊ฐ์ ‘pod install’๋ช
๋ น์ ์คํํฉ๋๋ค.
After installing the module, be sure to navigate to the ios directory and run the pod install command.
— pod install ๋ช
๋ น์ ์คํํ์ง ์์ผ๋ฉด ios์ฑ์ ๋ชจ๋์ด ์ ์ฉ๋์ง ์์ต๋๋ค.
If you do not run the pod install command, the module will not be applied to the iOS app.
โ https๊ฐ ์๋ httpํ๋กํ ์ฝ์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ httpํ๋กํ ์ฝ ํ์ฉ ์ค์ ์ ํด์ผํฉ๋๋ค.
Since we are using the http protocol instead of https, we need to allow the http protocol.
— info.plistํ์ผ์ ์์ ํฉ๋๋ค.
โ ํ์ผ์์น / file location : project/ios/project name directory/info.plist
— ํด๋ผ์ฐ๋/ํธ์คํ
์๋ฒ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์๋ ipaddress๋ ๋๋ฉ์ธ์ ์ฌ์ฉํ์๋ฉด ๋ฉ๋๋ค.
If you are using a cloud/hosting server, you can use ipaddress or domain.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>SocketMessage</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<!--httpํ์ฉ์ ์ํ ๋ณด์์ค์ -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>192.168.0.10</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<false/>
</dict>
</dict>
</dict>
<!--// httpํ์ฉ์ ์ํ ๋ณด์์ค์ -->
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
4)์คํ/Run
– npm install android ๋๋ npm install ios๋ช
๋ น์ด๋ก ์คํ ํ ์ ์์ต๋๋ค.
You can run it with the command npm install android or npm install ios.


3.NODEJS์ค์น / NODEJS install
1)์์ค์ฝ๋ ๋ค์ด ๋ฐ๊ธฐ
– ์์ ๊ตฌ๊ธ ๋๋ผ์ด๋ธ์์ nodejs+socketMessage/login+socketmessage ๋๋ ํ ๋ฆฌ๋ฅผ ๋ค์ด ๋ฐ์ต๋๋ค.
2)๋ชจ๋์ค์น / module install
— ๋จผ์ npm init๋ช
๋ น์ด๋ก package.jsonํ์ผ์ ์์ฑํฉ๋๋ค.
First, create a package.json file using the npm init command.
-package.jsonํ์ผ์์ ์๋ ๋ถ๋ถ์ ๋ชจ๋์ ๋ณผ ์ ์์ต๋๋ค.
You can see the modules in the following section in the package.json file.
"dependencies": {
"bcrypt": "^5.1.1",
"express": "^5.1.0",
"express-session": "^1.18.1",
"http": "^0.0.1-security",
"socket.io": "^4.8.1"
}
– npm install ๋ช
๋ น์ด๋ก ๋ชจ๋์ ์ค์น ํฉ๋๋ค. / Install the module using the npm install command.
npm install express express-session bcrypt http socket.io --save
3)์คํ / run
— node server.js๋ก nodejs์๋ฒ๋ฅผ ์์ํฉ๋๋ค.
Start the Node.js server with node server.js.
4)๋ธ๋ผ์ฐ์ ์์ http://localhost:3000์ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ๋ฉด์ ๋ณผ ์ ์์ต๋๋ค.
If you run http://localhost:3000 in your browser, you will see a screen like the following.

โป ๋ก๊ทธ์ธ ID๋ testuser,testuser2์ด๋ฉฐ ํจ์ค์๋๋ ๋ชจ๋ 11111111์
๋๋ค.
The login ID is testuser,testuser2 and the password is 11111111.