
Kategori
Demo ###


https://im.cookeem.com
Ubah ke dalam direktori cookim, jalankan perintah di bawah ini, mulai beberapa node server cookim dalam mode compose Docker. Cara ini akan memulai 3 wadah: mongo, cookim1 dan cookim2
$ git clone https://github.com/cookeem/CookIM.git
$ cd CookIM
$ sudo docker-compose up -d
Creating mongo
Creating cookim1
Creating cookim2Setelah menjalankan Docker Compose, gunakan Browser yang berbeda untuk mengakses URL di bawah ini untuk terhubung ke Cookim1 dan Cookim2
http: // localhost: 8080 http: // localhost: 8081
Kategori
Anda dapat menambahkan konfigurasi di docker-compose.yml (dalam direktori cookim) untuk menambahkan node server cookim, contoh ini menunjukkan cara menambahkan cookim3 di compose docker:
cookim3 :
image : cookeem/cookim
container_name : cookim3
hostname : cookim3
environment :
HOST_NAME : cookim3
WEB_PORT : 8080
AKKA_PORT : 2551
SEED_NODES : cookim1:2551
MONGO_URI : mongodb://mongo:27017/local
ports :
- " 8082:8080 "
depends_on :
- mongo
- cookim1Kategori
Lihat Output cookim1 Container Log
$ sudo docker logs -f cookim1 EXEC ke wadah cookim1 untuk men -debug
$ sudo docker exec -ti cookim1 bashKategori
$ sudo docker-compose stop
$ sudo docker-compose rmKategori
Kategori
git clone https://github.com/cookeem/CookIM.git
cd CookIMKategori
File konfigurasi menemukan di conf/application.conf , pastikan konfigurasi URI MongoDB Anda.
mongodb {
dbname = " cookim "
uri = " mongodb://mongo:27017/local "
} Proyek Cookim Assembly ke Fatjar, Target Jar Lokasi di target/scala-2.11/CookIM-assembly-0.2.0-SNAPSHOT.jar
sbt clean assemblyKategori
Cookim Gunakan MongoDB untuk menyimpan pesan obrolan dan data pengguna, pastikan Anda memulai MongoDB sebelum Anda memulai Cookim.
Ada dua cara untuk memulai Cookim Server: SBT dan Java
A. SBT Debug Way:
$ cd # CookIM directory#
$ sbt " run-main com.cookeem.chat.CookIM -h localhost -w 8080 -a 2551 -s localhost:2551 "B. Paket dan kompilasi toples lemak:
$ sbt assemblyC. Java Production Way:
$ java -classpath " target/scala-2.11/CookIM-assembly-0.2.4-SNAPSHOT.jar " com.cookeem.chat.CookIM -h localhost -w 8080 -a 2551 -s localhost:2551Perintah di atas telah memulai server web mendengarkan port 8080 dan sistem akka mendengarkan port 2551
Parameter:
-a -h [-m ] [-n] -s -w -a,--akka-port akka cluster node port -h,--host-name current web service external host name -m,--mongo-uri mongodb connection uri, example: mongodb://localhost:27017/local -n,--nat is nat network or in docker -s,--seed-nodes akka cluster seed nodes, seperate with comma, Contoh: LocalHost: 2551, LocalHost: 2552 -W,-Port Layanan Web-port Web-port
Kategori
http: // localhost: 8080
Kategori
Buka terminal lain, mulailah server cookim lain untuk menguji komunikasi pesan antar server:
A. SBT Debug Way:
$ sbt " run-main com.cookeem.chat.CookIM -h localhost -w 8081 -a 2552 -s localhost:2551 "B. Java Production Way:
$ java -classpath " target/scala-2.11/CookIM-assembly-0.2.0-SNAPSHOT.jar " com.cookeem.chat.CookIM -h localhost -w 8081 -a 2552 -s localhost:2551Perintah di atas telah memulai server web mendengarkan port 8081 dan sistem akka mendengarkan port 2552
Kategori
http: // localhost: 8081
Kategori

** Cookim Server Make dari 3 bagian: **
- Akka HTTP: Menyediakan Layanan Web, Browser Connect Server Obrolan Terdistribusi oleh Websocket
- AKKA Stream: Akka http Menerima pesan WebSocket (pesan WebSocket menyertakan TextMessage dan BinaryMessage), lalu kirim pesan ke ChatService oleh Akka Stream Way, pesan WebSocket termasuk JWT (Token Web Javascript), jika JWT memverifikasi kegagalan, ChatService Stream akan mengembalikan pesan RECT RECT; Jika JWT Verifikasi Sukses, Stream CHATSERVICE akan mengirim pesan ke ChatSessionactor
- Akka Cluster : AKKA Stream Kirim pesan WebSocket ke AKKA Cluster ChatSessionactor, ChatSessionactor Gunakan DistributedPubSub untuk berlangganan dan menerbitkan pesan di Akka Cluster. Ketika sesi online pengguna, itu akan berlangganan sesi; Saat pengguna mengirim pesan dalam sesi, itu akan mempublikasikan pesan di Akka Cluster, para aktor yang berlangganan sesi akan menerima pesan publikasi
Kategori

- WebSocket Message Body termasuk JWT, FLOWFROMWS digunakan untuk menerima pesan WebSocket dan mendekode JWT;
- Ketika JWT memverifikasi kegagalan, itu akan disiarkan ke filterfailure untuk memfilter pesan gagal; Ketika JWT memverifikasi kesuksesan, itu akan disiarkan ke filtersuccess untuk memfilter ke pesan sukses;
- Ketika AKKA Stream dibuat, builder.MATERIALICEVALLUE akan mengirim pesan ke ConnectedWS, ConnectedWS Convert Message menerima ke pesan UserOnline, lalu kirim ke ChatSinkactor akhirnya mengirim ke ChatSessionactor;
- ChatactorSink mengirim pesan ke ChatSessionactor, ketika AKKA Stream ditutup jika akan mengirim pesan UserOffline ke Down Stream;
- ChatSource menerima pesan kembali dari ChatSessionactor, lalu kirim pesan kembali ke Flowacceptback;
- Flowacceptback akan membiarkan koneksi WebSocket Keepalive;
- Pesan FlowReChject dan Flowacceptback akhirnya mengirim ke FlowbackWS, FlowbackWS mengonversi pesan ke format WebSocket kemudian mengirim kembali ke pengguna;
Kategori
*login (login email)
nickname (nickname)
password (password SHA1)
gender (gender: unknow:0, boy:1, girl:2)
avatar (avatar abs path, example: /upload/avatar/201610/26/xxxx.JPG)
lastLogin (last login timestamp)
loginCount (login counts)
sessionsStatus (user joined sessions status)
[{sessionid: session id, newCount: unread message count in this session}]
friends (user's friends list: [friends uid])
dateline (register timestamp)
*createuid (creator uid)
*ouid (receiver uid, when session type is private available)
sessionIcon (session icon, when session type is group available)
sessionType (session type: 0:private, 1:group)
publicType (public type: 0:not public, 1:public)
sessionName (session name)
dateline (created timestamp)
usersStatus (users who joined this session status)
[{uid: uid, online: (true, false)}]
lastMsgid (last message id)
lastUpdate (last update timestamp)
*uid (send user uid)
*sessionid (relative session id)
msgType (message type)
content (message content)
fileInfo (file information)
{
filePath
fileName
fileType
fileSize
fileThumb
}
*dateline (created timestamp)
*uid (online user id)
dateline (last update timestamp)
noticeType (notification type: "joinFriend", "removeFriend", "inviteSession")
senduid (send user id)
*recvuid (receive user id)
sessionid (relative session id)
isRead (notification is read: 0:not read, 1:already read)
dateline (created timestamp)
Kategori
Ada dua saluran websocket: ws-push dan ws-chat
WS-Push mengirim sesi pesan baru untuk pengguna, saat pengguna tidak online sesi, mereka masih dapat menerima sesi mana yang memiliki pesan baru
/saluran WS-Push
up message, use to subscribe push message:
{ userToken: "xxx" }
down message:
acceptMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "accept", content: "xxx", dateline: "xxx" }
rejectMsg: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "", sessionIcon: "", msgType: "reject", content: "xxx", dateline: "xxx" }
keepAlive: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "", sessionIcon: "", msgType: "keepalive", content: "", dateline: "xxx" }
textMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "text", content: "xxx", dateline: "xxx" }
fileMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "file", fileName: "xxx", fileType: "xxx", fileid: "xxx", thumbid: "xxx", dateline: "xxx" }
onlineMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "online", content: "xxx", dateline: "xxx" }
offlineMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "offline", content: "xxx", dateline: "xxx" }
joinSessionMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "join", content: "xxx", dateline: "xxx" }
leaveSessionMsg:{ uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "leave", content: "xxx", dateline: "xxx" }
noticeMsg: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "xxx", sessionIcon: "xxx", msgType: "system", content: "xxx", dateline: "xxx" }
message push to browser:
pushMsg: {
uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "xxx",
content: "xxx", fileName: "xxx", fileType: "xxx", fileid: "xxx", thumbid: "xxx",
dateline: "xxx"
}
Kategori
WS-CHAT adalah saluran obrolan sesi, pengguna mengirim dan menerima pesan sesi di saluran ini
/ws-chat channel
up message:
onlineMsg: { userToken: "xxx", sessionToken: "xxx", msgType:"online", content:"" }
textMsg: { userToken: "xxx", sessionToken: "xxx", msgType:"text", content:"xxx" }
fileMsg: { userToken: "xxx", sessionToken: "xxx", msgType:"file", fileName:"xxx", fileSize: 999, fileType: "xxx" }<#BinaryInfo#>binary_file_array_buffer
down message:
rejectMsg: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "", sessionIcon: "", msgType: "reject", content: "xxx", dateline: "xxx" }
keepAlive: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "", sessionIcon: "", msgType: "keepalive", content: "", dateline: "xxx" }
textMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "text", content: "xxx", dateline: "xxx" }
fileMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "file", fileName: "xxx", fileType: "xxx", fileid: "xxx", thumbid: "xxx", dateline: "xxx" }
onlineMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "online", content: "xxx", dateline: "xxx" }
offlineMsg: { uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "offline", content: "xxx", dateline: "xxx" }
joinSessionMsg:{ uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "join", content: "xxx", dateline: "xxx" }
leaveSessionMsg:{ uid: "xxx", nickname: "xxx", avatar: "xxx", sessionid: "xxx", sessionName: "xxx", sessionIcon: "xxx", msgType: "leave", content: "xxx", dateline: "xxx" }
noticeMsg: { uid: "", nickname: "", avatar: "", sessionid: "", sessionName: "xxx", sessionIcon: "xxx", msgType: "system", content: "xxx", dateline: "xxx" }
message push to browser:
chatMsg: {
uid: "xxx", nickname: "xxx", avatar: "xxx", msgType: "xxx",
content: "xxx", fileName: "xxx", fileType: "xxx", fileid: "xxx", thumbid: "xxx",
dateline: "xxx"
}
Kategori
Kategori
Kategori
Kategori