์๋ ,
GAE Fixble(Google ์ฑ ์์ง)์ ํ๋๋ฅผ ๋ฐฐํฌํ๊ณ ์ถ์ต๋๋ค.
์ํ๊น๊ฒ๋ Google App Engine์ ๋ก๋ ๋ฐธ๋ฐ์๋ ์น ์์ผ์ ์ง์ํ์ง ์์ต๋๋ค.
๊ทธ๋์ ๋๋จธ์ง API(80, 443)์ ๋ค๋ฅธ ์์ผ.io ์์ ํฌํธ๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
sokect.io์ ๋ํด ๋ค๋ฅธ ํฌํธ๋ฅผ ์ค์ ํ ์ ์์ต๋๊น?
๊ฐ์ฌ ํด์ .
๋ค์๊ณผ ๊ฐ์ด REST ๋ถ๋ถ์ ์์ํ ์ ์์ด์ผ ํฉ๋๋ค.
const http = require('http');
http.createServer(app).listen(80);
๊ทธ๋ฐ ๋ค์ ๋ค์์ ํตํด ์์ผ ์๋ฒ:
const socketServer = http.createServer().listen(3889);
app.setup(socketServer);
app.listen
๋ฅผ ํธ์ถํ์ง ๋ง์ญ์์ค.
๋์์ ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค. ์์ผ์ผ๋ก ์ฒ๋ฆฌํ ์ ์ IP๋ ์์ต๋๋ค.
ํ์ง๋ง GAE flexible์ ๋ฐฐํฌํ๋ ์ฒซ ๋ฒ์งธ ๋จ๊ณ๊ฐ ์์ต๋๋ค.
์ด๊ฒ์ ๋ด ํ์ฌ index.js์ ๋๋ค.
'use strict';
const http = require('http');
const app = require('./app');
const port = process.env.PORT || app.get('port');
const socketServer = http.createServer().listen(3889);
app.setup(socketServer);
const server = http.createServer(app).listen(port);
// app.listen(port);
server.on('listening', () =>
console.log(`Feathers application started on ${app.get('host')}:${port}`)
);
์ด์ GAE์ ๋ฐฐํฌํ ์ ์์ต๋๋ค . http://my-app.appspot.com ์ ์ฌ์ฉํ๊ณ ws://ip- address:3889 ๋ก ws๋ฅผ ํธ์ถํ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ ๋ซํ ํ ์ต๊ทผ ํ๋์ด ์์๊ธฐ ๋๋ฌธ์ ์๋์ผ๋ก ์ ๊ฒผ์ต๋๋ค. ๊ด๋ จ ๋ฒ๊ทธ์ ๋ํด์๋ ์ด ๋ฌธ์ ์ ๋ํ ๋งํฌ๊ฐ ์๋ ์ ๋ฌธ์ ๋ฅผ ์ฌ์ญ์์ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ค์๊ณผ ๊ฐ์ด REST ๋ถ๋ถ์ ์์ํ ์ ์์ด์ผ ํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ ๋ค์์ ํตํด ์์ผ ์๋ฒ:
app.listen
๋ฅผ ํธ์ถํ์ง ๋ง์ญ์์ค.