This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#767 Notification SockJS client enclosured to service
- Loading branch information
1 parent
7d92cda
commit 62e2cb2
Showing
6 changed files
with
122 additions
and
94 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import SockJs from 'sockjs-client'; | ||
import Stomp from 'stompjs/lib/stomp.min.js'; | ||
|
||
class Auth { | ||
constructor() { | ||
this.notificationClient = null; | ||
} | ||
|
||
initNotificationClient = (topic, cb) => { | ||
const sock = new SockJs(config.WS_URL); | ||
this.notificationClient = Stomp.Stomp.over(sock); | ||
this.notificationClient.debug = null; | ||
this.notificationClient.connect({}, () => { | ||
this.notificationClient.connected && | ||
this.notificationClient.subscribe(topic.data, msg => { | ||
cb && cb(msg); | ||
}); | ||
}); | ||
} | ||
|
||
closeNotificationClient = () => { | ||
this.notificationClient && this.notificationClient.disconnect(); | ||
} | ||
} | ||
|
||
export default Auth; |