-
Notifications
You must be signed in to change notification settings - Fork 10
Merging plugin with your own custom calls
vahidhedayati edited this page Sep 9, 2014
·
3 revisions
Since 0.15 a few new additions made - firstly you should attempt to match what the chat end point will be looking for as a user so all spaces and dots already converted to _ before setting session.wschatuser - which you must now set in order for the new featuers such as profiles to work from within a custom authenticated user.
class ChatterController {
def userService
def index() {
if (session.user) {
def chatTitle=grailsApplication?.config?.wschat.title ?: 'Grails Websocket Chat'
def chatHeader=grailsApplication?.config?.wschat.heading ?: 'Grails websocket chat'
def hostname=grailsApplication?.config?.wschat.hostname ?: 'localhost:8080'
def showtitle=grailsApplication.config.wschat.showtitle ?: 'yes'
def chatuser=userService.returnRealUser(session.user)
def dbSupport=grailsApplication.config.wschat.dbsupport ?: 'yes'
chatuser=chatuser.trim().replace(' ', '_').replace('.', '_')
session.wschatuser=chatuser
def dbrooms
def room=grailsApplication.config.wschat.rooms[0]
if (dbSupport.toString().toLowerCase().equals('yes')) {
dbrooms=ChatRoomList?.get(0)?.room
}
if (dbrooms) {
room=dbrooms
} else if (!room && !dbrooms) {
room='wschat'
}
session.wschatroom=room
render (plugin: 'wschat', view : '/wsChat/chat', model: [dbsupport:dbSupport.toLowerCase() , showtitle:showtitle.toLowerCase(), room:room, chatuser:chatuser, chatTitle:chatTitle,chatHeader:chatHeader, now:new Date(),hostname:hostname])
}else{
flash.message="You must be logged in to use this feature"
}
}
In this controller I have defined the actual values I wish to pass to the plugin, and defined chatuser to go off and look up logged in user, then return their real name for the chat room